Difficulties Of Push Notifications In A Flutter App

I learnt it the hard way, after almost two and a half day of try-and-error. Most of the documentations in Flutter community are outdated and incomplete, bear that in mind, it’s a Google thing. The only practical solution to receive notifications in our app was using FCM because, God who wants to deal with Event Chanels. We were using Pinpoint to send notifications which makes it even more difficult. What we had to do on our backend was constructing a GCM message instead of two different ones for iOS and Android (we compile the code for these two). Also since we registered the device with our backend as well as FCM, we had to use fcmas the platform for Android, iOS and iOS Sandbox. On the front-end to get token getToken() method should have been used for both platforms but we were using getAPNSToken() for iOS devices which was one of the reasons for notification not working (was I careless?). The other reason which was even more frustrating was that we didn’t have notification key in our initial payload and for this reason FCM SDK was not calling completion handler in application:didReceiveRemoteNotification:fetchCompletionHandler:which is a disappointing behaviour for a SDK as big and popular as Firebase. With these fixes we finally could receive Push Notifications with our app.

 

P.S. I originally published it on Medium

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.