Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to handle ios push notification inside code #488

Open
abarone-btf opened this issue Dec 10, 2024 · 7 comments
Open

How to handle ios push notification inside code #488

abarone-btf opened this issue Dec 10, 2024 · 7 comments
Labels
platform-ios Specific to iOS platform support Asking for help writing an application

Comments

@abarone-btf
Copy link

abarone-btf commented Dec 10, 2024

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

@deepak786 deepak786 added platform-ios Specific to iOS platform support Asking for help writing an application labels Dec 16, 2024
@deepak786
Copy link
Collaborator

deepak786 commented Dec 16, 2024

@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.

@abarone-btf
Copy link
Author

abarone-btf commented Dec 16, 2024

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) 😭

@il2be97
Copy link

il2be97 commented Dec 17, 2024

@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.
image

@deepak786
Copy link
Collaborator

Yes, Intercom uses APNs to send the notification on iOS.
FCM is used for Android only.

@abarone-btf
Copy link
Author

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 😞 )

@il2be97
Copy link

il2be97 commented Dec 17, 2024

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:

  1. Create your own plugin for IOS (https://apparencekit.dev/blog/flutter-create-plugin/)
  2. Make it directly in you AppDelegate.

@il2be97
Copy link

il2be97 commented Dec 19, 2024

@abarone-btf if still relevant - you can try to use this plugin (or simply duplicate the code)

https://github.com/il2be97/notification_handler_plugin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform-ios Specific to iOS platform support Asking for help writing an application
Projects
None yet
Development

No branches or pull requests

3 participants