How to handle ios push notification inside code
More than issue is a question/advice in how can I run a function when a push notification is sent by intercom.
I tried to use firebase_messaging callbacks but on iOS none of them work (its never executed).
Is there a tutorial in how to execute dart logic when a notification sent from intercom is received? (iOS particularly)
Why you may ask:
- I want to use a firebase dynamic link into intercom UI when sending a notification. On Android it redirect correctly but on iOS the redirection does not work. So I want to debug what is arriving but the callbacks are never called 😢
Thanks for your help
@abarone-btf Maybe this is helpful https://developers.intercom.com/installing-intercom/ios/push-notifications#step-4-handling-intercom-push-notifications Specially the "Manually" part.
You may also need to setup "IntercomUniversalLinkDomains".
Note: As per my personal experience, even after setting the IntercomUniversalLinkDomains, the clicks from Intercom are opening the Safari browser. They are not opening the particular screen or page. I'm also using the Firebase dynamic links.
Thank you @deepak786 !. I tried to put that config into the plist but dont know how to handle the intercom logic inside my flutter app. Do you know how to do it? (sorry if its a noob question).
In my case the links open my app just fine but just redirect to the home page (they do not redirect to the particular page, doesnt matter what I put in the intercom website) 😭
@abarone-btf firebase_messaging support only notifications which are received from the firebase. If you wanna handle other (intercom) notifications - you should create your own event channel and handle it by your own
on IOS side it should looks approximately like on attached image (here you are listening all tapped notifications and send it to your flutter code) - on flutter side you can check if notification is Intercom and handle it.
Yes, Intercom uses APNs to send the notification on iOS. FCM is used for Android only.
Thats good to know!. Thank you very much for the image! @il2be97 . By any chance do you know (or have a post/project) that implements this behavior entirely? (the ios part and the flutter part) to follow a guide to implement it correctly. I searched some of this but the posts i've found are not as clear as I expect (almost all of them asume you use Firebase 😞 )
I haven't seen any good packages which provided that behavior. Also image which I attached - it is a solution on which i am working right now, so it hasn't been ready and i can share it only when i will finish it
So I can explain how you can do this he same thing: You need create EventChannel and share Native code to Flutter code (https://medium.com/@atifqamar29/event-channels-in-flutter-827ef357c2d1).
You have two ways to do that:
- Create your own plugin for IOS (https://apparencekit.dev/blog/flutter-create-plugin/)
- Make it directly in you AppDelegate.
@abarone-btf if still relevant - you can try to use this plugin (or simply duplicate the code)
https://github.com/il2be97/notification_handler_plugin