4

I'm working on an app that receives push notifications from Zenpush service. I managed to set up both app and account on Zenpush to sent and receive notifications.

When the app is active (opened) and I receive notification - everything is OK. I handle this in application:didReceiveRemoteNotification:.

Also, I can handle notification when user taps on it when it arrives, or opens app from the notification center.

The issue is - I can't handle notifications if the app is in the background, or terminated. I've been struggling with this for a week now. I have both Background fetch and Remote notifications enabled in Background modes. In Scheme I checked "Launch due to background fetch event". According to Apple documentation and what I've found on StackOverflow I'm using following method to handle notifications in the background: application:didReceiveRemoteNotification:fetchCompletionHandler:.

No matter what i send in notification, this method is not called. I tried to determine this by making changes to some data, and trying to NSLog something.

https://devforums.apple.com/message/873265#873265

I include "content-available": 1 in my notifications.

Is there something else I'm missing? Or maybe there is a way to get all notifications that was receiver while app was in background/terminated where the app becomes active?

Kolineal
  • 465
  • 5
  • 12
  • Related: http://stackoverflow.com/q/19068762/2446155 – Andrew Apr 01 '14 at 15:31
  • You should be able to handle notifications through that method when the app is in the *background*, just not when it is *terminated* (by swiping up in app switcher) – Andrew Apr 01 '14 at 15:34
  • @SantaClaus I've tried using the code in the related question that you mentioned. But the app still not reacting to notification. – Kolineal Apr 01 '14 at 15:40
  • Try *unchecking* "Launch due to background fetch event" in your Scheme. This is a debug feature meant to simulate launching due to a background fetch, but you want to test using a normal launch. – Andrew Apr 01 '14 at 17:30

1 Answers1

1

Stil not being able to get app to call application:didReceiveRemoteNotification:fetchCompletionHandler: I decided to debug what exactly i receive from Zenpush. Turns out, using their Custom Payload section to add content-available is not the right way to do it. This way content-available is added after asp object, not inside of it.

I wrote to Zenpush support about it, if i get any info on how to send content-available inside asp i will edit this answer

Update:

I got the response from Zenpush support. This feature is tested now, and will be available soon.

Update 2:

Zenpush added a checkbox for background services, and now it works just fine. enter image description here

Kolineal
  • 465
  • 5
  • 12
  • i am also working with the same scenario but i am using FCM . i am also stuck like you that i could not open push notification until i tap on the notification message . do you have any idea regarding how to solve this with FCM ? – Moxarth Jul 13 '17 at 11:49