4

I am trying to implement silent push notification in my application where I need to update some data in the server when silent notification comes. I am using Pushkit and it uses VoIP certificate for silent push notification but the app has been rejectd by Apple saying that "I can't use VoIP" certificate. It seems that apple has rejected it as I don't have any VoIP call functionality in my app. In that case how can I implement silent push notification so that my app gets activated even if it is not runnning(not even in the background) and I can update the server?

radikalarijit
  • 61
  • 1
  • 4
  • You can use VoIP background mode only when you can actually implementing VoIP based functionality in your app. And there's no way to wake up application if user kills app from app switcher. – nikBhosale Jun 27 '18 at 13:45

1 Answers1

2

From my experience, iOS respects user's choice, so in case the user has killed the app, it will remain killed - no silent push notification will wake this app. VoIP is an exception to that, but as you wrote, it should be used only in VoIP apps. This makes sense, consider it a platform limitation: thanks to that user have some control over what is actually running on the phone, the device consumes less battery and lastly, foreground/system Apps has the most CPU time to utilize.

There are few techniques to work with data in the background:

  1. Content-available push notification: will wake up the application in case it is suspended, or startup it in case it has been killed by the system/crashed. Note, that this only opens a 30-second window and amount of notifications is throttled by APNS.
  2. Background fetch capability will act in a similar manner.
  3. Background task to finish existing task - but this is only used when app is moved to the background.

If you need App to send updates to the server, I believe above should be sufficient (unless your app is spying on a user, it should have all relevant data available once the user finishes interaction with the App).

If you need a server to send data to the App, use silent push notification (or background fetch for periodic pulling), or in case this data is critical to the user, you can present him a remote notification - if the user considers that an important update, he will open the app.

deekay
  • 899
  • 6
  • 8
  • 1
    Silent push notification works just like a normal push notification, only it wont produce a banner. "no silent push notification will wake this app" , this is incorrect. In case of silent push notification, when a notification arrives, OS activates app's appdel and `didRecieveNotification` is called with a time limit of 30-60 seconds. – Saheb Roy Jun 27 '18 at 07:45
  • Last time I tested it on a device (this was prior to iOS 11), silent push notification was not received in case I explicitly *killed* the app. It did wake up the app in case it was running suspended in the background. – deekay Jun 27 '18 at 08:06
  • No it does wake up application, but a user wont be able to understand it, as OS wakes it up in a suspended state, NOT active state – Saheb Roy Jun 27 '18 at 08:07
  • I just tested it on iOS 11 with production app: server sent regular (non-VoIP) content available push notification and iOS did not wake up application after it was killed. – deekay Jun 27 '18 at 08:13
  • How are you testing it? are you changing the scheme to wake up in an event? How are you debugging the Phone to be in a state of terminated while in debug? – Saheb Roy Jun 27 '18 at 08:18
  • Waking up an application will NOT be notified to a user as i mentioned, as the User or even in DEBUG you wont be able to see the application getting active. The application gets activated by the OS in a suspended. If you have a doubt then write a code in application did recieve that writes the timestamp in a plist. Check the plist later on – Saheb Roy Jun 27 '18 at 08:20
  • I am simply attaching the device to Mac, then open Xcode->Devices, select connected device, then press 'Open Console'. You will see in the console logs from the system and all applications. Once killed, no message related to a killed app is being printed. If app is suspended, logs are visible. No need to change the scheme at all, I used app store version. – deekay Jun 27 '18 at 08:20
  • Ofcours once killed the debug is getting closed, isnt that obvious?? Once i kill the application the application's debug mode is off and xcode is not linked to the application anymore. In this way you cannot test events like Silent notification, where the initial step of the application is a terminated, and then the event wakes it up to a suspended mode. Change the working sceme and tick the button which says "Launch due to background fetch mode" in Run-> Options. Now click on Run, the application will be awaked in a terminated stage. Put a breakpoint in didRecieve and fire the notification – Saheb Roy Jun 27 '18 at 08:23
  • I think you are misunderstanding me. I did not start the app from the Xcode. I am using Xcode to access device console. This is a completely different thing. I also wrote I am testing it on an application that was downloaded from the AppStore. – deekay Jun 27 '18 at 08:24
  • Oh, i thought it was in debug mode and you are launching fro xcode. – Saheb Roy Jun 27 '18 at 08:25
  • I can confirm that Content-available push notification is a right solution here - no other ways to do what you want – Rubycon Jun 28 '18 at 14:30