Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to debug a silent remote notification

I couldn't find anywhere how to debug a silent remote notification.

I know that a normal remote notification can be debugged by setting the project scheme to "wait for executable to be launched" but since a silent remove notification doesn't open the app, it didn't work.

I'm also not sure which method should be called when i get a silent remote notification. Already tried:

-application:didFinishLaunchingWithOptions
-application:didFinishLaunching
-application:didReceiveRemoteNotification
-application:didReceiveRemoteNotification:fetchCompletionHandler
-application:handleActionWithIdentifier:forRemoteNotification:completionHandler

None of these worked...

This is my payload:

{
  "aps": {
    "content-available": 1,
    "sound":"silent.wav"}
}

Can anyone help me with that?

like image 953
Nimrod Shai Avatar asked Oct 15 '25 09:10

Nimrod Shai


1 Answers

What's happening is you've got an incorrect payload. In order for it to be considered a silent push notification that will trigger a background fetch, the only thing allowed in the "aps" dictionary is "content-available":1. Since you have a sound, the system ignores the content-available part and sends it on as a regular notification. And since there's no "alert" portion, there's no notification to interact with and no way to launch your app. Remove the sound part and your notification will come through -application:didReceiveRemoteNotification:fetchCompletionHandler

It makes no difference if your app is running in the background or hasn't been started on the device. If the app is not running, iOS will wake it up and deliver the notification after the app launches in the background. If it's been run but it's backgrounded or it's running in the foreground, the notification will simply be delivered to your app. No matter what it still goes to the same method.

There are two other requirements for this to work:

  1. Your device has to have background fetch enabled for your app.
  2. You can't have killed the app manually by swiping up from the multitasking UI. If you do this, iOS will NEVER wake up the app until it is ran by the user again.
like image 195
Lance Avatar answered Oct 16 '25 22:10

Lance



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!