0

I trying silent push notification to wake app in background and calling a specific Api but it doesn't work properly

-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler{//Fetching data using AfNetworking
completionHandler(UIBackgroundFetchResultNewData);}

By the way : whatsApp doing something like this: notify the sending user that the message is delivered to receiving user

khaled
  • 865
  • 9
  • 24

3 Answers3

0

Silent notifications will NOT arrive when: - background fetching is disabled - the user has killed the app by sliding up from the app chooser screen

WhatsApp most likely sends notifications that has an 'aps' payload (which will cause iOS to display it on the notification screen), and the 'content-available' flag present (which will cause iOS the forward it immediately to you app, if not prevented by the 2 conditions above). Once the app is opened by the user, the app will let the server know which messages have been displayed on screen. The server could then send a silent push, or have the app poll while active, to update the checkmarks on screen. The thing to remember is that push notifications are not reliable sources o truth. They are 'pinging' the app, and the app and server need to implemented the actual logic.

Joride
  • 3,722
  • 18
  • 22
  • But i remove whatsApp by slipping up from the app chooser screen and when i send this phone message it tell me delivered – khaled Jan 03 '16 at 15:31
  • Also disabling background refresh and whatsApp mechanism of delivery works any suggestions? – khaled Jan 03 '16 at 15:33
  • 'Regular' push notifications will arrive (as per the settings in the Setting app off course). When you kill the app, or turn off background fetching, notifications are ONLY delivered to you app when the user taps on them. The silent part is then gone (the silent part means: when a push comes into iOS, it is delivered to your app without user interaction). – Joride Jan 03 '16 at 16:28
  • But i try silent notifications it delivers to my app once the app in background but does not deliver when the app is killed – khaled Jan 03 '16 at 16:31
  • Yes, this is expected: silent notifications come in if the app is not killed by the user, and background fetching is enabled (and the regular notifications settings also do not prohibit the receipt of notifications). Note that 'background fetching' is not the same as 'app in the background'. Background fetching is a setting for your app in the Settings app. – Joride Jan 03 '16 at 16:56
  • I know all of that my problem with " app killed by user " – khaled Jan 03 '16 at 17:01
  • 1
    It doesn't receive but in whatsApp works when I killed the app any suggestions? – khaled Jan 03 '16 at 17:01
  • If whatsapp is killed, it does not receive silent notifications. You will see the 'regular' part of the notification on the screen of course as usual. When you open whatsapp, the app calls their server, downloads any new messages. Now the server nows the messages are received. When the messages are displayed, the app will call the server to tell it these messages where shown. Now, the server can tell the sender via another push that the message has been displayed. Or, the receiving ends is polling the server, also possible. Important to realize is that this is all done without relying on APNS – Joride Jan 03 '16 at 17:46
  • Can you try it with another iphone device 1- kill your whatsApp and make the other phone send you a message it will marked as deliver 2- disconnect your mobile from wifi and send message again it will not deliver until you open wifi again without open the app can you try it ? – khaled Jan 03 '16 at 18:18
  • Horide you answers are not relible because Khaled is telling truth when app is kill and whe you send the message to other user if other user receive the notification then you delivery status will be delivered 2nd and when app wifi or Data Connection is close its will show you single Tick, how the whats app is doing this? and when you have a call to ios WhatsApp its will show your name if number is save in Contact list! when app is in Kill Status! can any body help for this? – Shakeel Ahmed Jul 01 '19 at 05:30
0

Push notifications are fire-and-forget by design, and they're not even guaranteed to be delivered to client device. So no, you cannot confirm delivery of a push message.

WhatsApp and other messengers must be using their own infrastructure to track messages' delivery.

Alex Skalozub
  • 2,511
  • 16
  • 15
0

I found Working around on this Problem and Answer it at this question

Silent push notifications only delivered if device is charging and/or app is foreground

Community
  • 1
  • 1
khaled
  • 865
  • 9
  • 24