Silent Notification Issues without Xcode on iOS 8

2019-07-20 19:51发布

问题:

I've been testing out the Silent Notification feature that is available since iOS 7.

My application is targeting iOS 7 and UP.

I'm testing on an iPhone6 device.

Everything seems to work great in my application when my iPhone is connected to the computer & Xcode is running the application. All silent notifications work 100% and they show up in my application as well.

However, if I stop Xcode & send a silent notification -- my device does not receive the silent notifications at all.

I have done a LOT of research but nothing has given me an answer nor has helped me determine what is going on.

I have not killed my application. So, that is not the issue. You can still see the application in the app switcher.

My application does receive regular push notifications (with and without Xcode). The issue is with Silent Notifications.

Found these (but they did not help me solve the issue):

  1. IOS 8 Silent push notification not working without Xcode
  2. iOS silent push notification only works when connected to xcode

I have added the "Priority" tag to my JSON payload as well... and still no luck.

This is my Payload:

$body['aps'] = array( 'content-available' => 1, 'alert' => $message, 'Priority' => 10, 'sound' => 'default' );

I've even tried "priority" all lower-cased.

My phone does get the alert and it makes the sound. But, if a user selects the "app icon" instead of the banner alert -- it doesn't get the silent notification. This only happens when my application isn't connected and running from Xcode.

Also, I am using a Developer certificate and Provisioning Profile.

UPDATE 1:

Found out that the Priority setting is supposed to be apart of the binary notification not the APNS Payload.

I removed "priority" from payload and configured binary notification as Command 2.

See: https://developer.apple.com/library/mac/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/CommunicatingWIthAPS.html

Tested with Xcode. Everything works. Tested without Xcode. Still same issue. =(

UPDATE 2

I tested the application on an iPhone 4 Device. Silent Notifications work with or without Xcode on it. So, this must be an issue strictly with iOS 8 devices.

Updating title to reflect only iOS 8. I'm not sure how to fix this for iOS 8 devices. Anyone have any suggestions?

回答1:

Okay, so I finally solved why the silent notification wasn't working on iOS 8 devices.

In the binary notification that you send from the PHP script, the priority must be set to 5. It will not work with a 10 when you are not running your application from Xcode.

I don't know why the application worked with a 10 when running from Xcode -- this is why it was so hard to determine what was wrong. I also don't know why a priority of 10 worked for iOS 7 devices.

SEE: https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/CommunicatingWIthAPS.html