Rafael
Rafael

Reputation: 117

Receive notifications from firebase in background on IOS App?

I am creating a framework that can receive custom (a certain data model) messages from firebase. The framework is going to be implemented to receive notifications that are not related with the app but with other stuff.

So the framework is going to handle all the display issue by translating the data received and create a notification as it is indicated (I have some flags in data receive that indicated if I should use an image or attach an icon .. etc).

So I did some research on how to receive messages from FCM.

In first instance, I found direct channel that allows to bypass APNS, the problem is that, this only works with the app in foreground.

I indeed create a test project in firebase, a single view app, register my app in firebase project, set info.plist, configure , and send a notification to my app and It worked (just when the app was open).

Then I looked for another choice, and I found APNS. Skiping all the process for validation between firebase and APNS. I found that when you have all set up (and you put all initialization in didAplicationFinishLaunching) your app is able to receive notifications from firebase (Through APNS) when applicaton is in background.

But, notification received (the one that gets displayed) is just for you to tap over it and then it will fire up the app again an only then you will receive the whole data in aplication:didReceiveRemoteMessage method.

My question is, is there a way I can get this custom messages even in background and when received I can display a notification with the content of the whole message?

Upvotes: 0

Views: 726

Answers (1)

Hammer Class
Hammer Class

Reputation: 371

Yes,

Fortunately you can do that but for that you need to send Silent Notification which will let you process the notification in background and schedule local notification to trigger it with you desired data.

Upvotes: 1

Related Questions