推送通知在商店中不起作用

问题描述:

我将通过rails backend向ios设备发送通知。
我已将grocer gem添加到Gemfile中,然后将其安装到项目中。推送通知在商店中不起作用

gem 'grocer' 

我计划在后台模式下发送通知。所以我创建了resque作业,并在app/jobs/notificationsender.rb中添加了这样的grocer逻辑。

def self.perform(language) 
    @lang = language 

    # Thread.new do 
     while true 

     begin 
      pusher = Grocer.pusher(certificate: "#{Rails.root}/lib/notification/cer.pem", # required 
         passphrase: "llvc",       # optional 
         gateway:  "gateway.sandbox.push.apple.com", # optional 
         port:  2195,        #optional 
         retries:  3) 

     feedback = Grocer.feedback(certificate: "#{Rails.root}/lib/notification/cer.pem", # required 
            passphrase: "llvc",       
            gateway:  "feedback.sandbox.push.apple.com", 
            port:  2196,      
            retries:  3) 

     note = Grocer::Notification.new(
      device_token: device_token, 
      alert: message, 
      sound: 'default', 
      badge: 0, 
      expiry: Time.now + 60*60, 
      content_available: true, 
      custom: { 
      "linkname": linkname, 
      "linkurl": linkurl 
      } 
     ) 

     feedback.each do |attempt| 
      puts "Device #{attempt.device_token} failed at #{attempt.timestamp}" 
     end 

     pusher.push(note) 
     rescue Exception => e 
      puts e.class 
      puts e 
     end 

     sleep(5) 
     end #while 
    end 

我从iPhone获得了一个设备令牌并将其发送到后端。

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { 
    _deviceToken = deviceToken; 

    // Store the deviceToken in the current installation and save it to Parse. 
    if (currentInstallation == nil) { 
     currentInstallation = [[BSGInstallation alloc] init]; 
    } 

    currentInstallation.delegate = self; 
    [currentInstallation setDeviceTokenFromData:deviceToken]; 
    [currentInstallation saveInBackground]; 
} 

我下载了一个苹果pushnotification开发证书,并从中产生P12,然后创建命令行cer.pem文件。
我使用应用程序开发cer签署了ios项目,以进行调试和分发以及分配开发配置。当然,我正确地将设备标识符添加到配置中。
在构建ios,后端,重新调用作业后,我在iPhone中每隔5秒钟后收到通知。我在iPad上安装了该应用程序。但通知不会在iPad上显示。当然,iPhone和iPad的ID是正确注册的。我确认iPhone和ipad的设备令牌已通过Grocer :: notification.new()
,但通知在iPad中无法使用。所以我重置服务器并重新安装在每个设备上。起初,我测试了iPad。结果是一样的。然后我转移到iPhone上。该系统也没有在iPhone上工作。在它工作之前。这很奇怪。
所以我想知道以下几点。
1)iphone或ipad收到通知的原因。我想知道尽可能多的分支,以便我可以按照步骤快速检测原因。
2)我可以检查通知是否到达APNS?
感谢您阅读我的长篇描述。

IOS和rails代码中没有错误。
我已经在ios上签了一个代码并通过url创建了一个pem文件。
https://www.raywenderlich.com/32960/apple-push-notification-services-in-ios-6-tutorial-part-1
我按照github教程时出错。 谢谢。