intercom_flutter icon indicating copy to clipboard operation
intercom_flutter copied to clipboard

Deep links + push notifications don't seem to work

Open vishna opened this issue 3 years ago • 12 comments

👋 Hello there,

First off, many thanks for this fantastic package - good job 💪

The Bug

When issuing a push notification via Intercom with a deep link (custom scheme) the push will appear on the device however pressing the push doesn't route properly to the given route.

Screenshot 2022-01-08 at 13 36 26
PlatformDispatcher.instance.defaultRouteName // this returns `/` always

Just to verify my deep links are implemented correctly, if I run:

xcrun simctl openurl booted app://open/settings

My app will route to the correct path:

PlatformDispatcher.instance.defaultRouteName // this returns `/settings` 

Desired behaviour

When notification is tapped, user is routed to the appropriate screen - we have some sort of access to the path to which user is supposed to be routed.

More context

  • I followed intercom instructions for deep-linking (custom url scheme)
  • Everything else intercom related works ok.
  • It seems someone has a similar issue in React Native
  • I tried adding uni_links package to maybe see if something is reported on the native side - unfortunately 😞

vishna avatar Jan 08 '22 12:01 vishna

Hi @vishna,

Thanks for reporting this issue.

So the universal links are working but not the custom schemes, right? Could you please provide the reproducible sample so that I can also test and try to find the solution?

deepak786 avatar Jan 10 '22 14:01 deepak786

also could you please try by adding the parameter FlutterDeepLinkingEnabled in info.plist according to https://docs.flutter.dev/development/ui/navigation/deep-linking#migrating-from-plugin-based-deep-linking

Also check this link https://www.raywenderlich.com/books/flutter-apprentice/v1.0/chapters/8-deep-links-web-urls

deepak786 avatar Jan 10 '22 15:01 deepak786

@deepak786 hey there,

I'm not using universal links so can't say, but custom schemes are not working... I'm actively investigating it, providing a sample might take a while.

I now got it working on iOS, the reason for it not working was IntercomAutoIntegratePushNotifications set to NO (using FCM https://github.com/v3rm0n/intercom_flutter/issues/29#issuecomment-876453494 )

Turning it back to YES made the app route correctly. Thus it's something in Intercom SDK that assigns deeplinks to incoming pushes. FCM pushes seem to be working fine too so far.

As per Flutter's initialRoute it's still reported as /. This means intercom sdk pushes the target route somehow later - I've worked around it by having tracking route guards (using autoroute).

Sidenote: I would not recommend using uni_links package for figuring out initial route as it overrides native code and some of the deep links stop working because of that (the navigation event is not bubbled up)

I think I have iOS covered, just need to check if it's all good on Android.

vishna avatar Jan 10 '22 15:01 vishna

also could you please try by adding the parameter FlutterDeepLinkingEnabled in info.plist according to https://docs.flutter.dev/development/ui/navigation/deep-linking#migrating-from-plugin-based-deep-linking

Also check this link https://www.raywenderlich.com/books/flutter-apprentice/v1.0/chapters/8-deep-links-web-urls

can you try this?

deepak786 avatar Jan 10 '22 15:01 deepak786

@deepak786 I have this already enabled and followed that page 😉

vishna avatar Jan 10 '22 15:01 vishna

I now got it working on iOS, the reason for it not working was IntercomAutoIntegratePushNotifications set to NO (using FCM #29 (comment) )

So we have to keep the IntercomAutoIntegratePushNotifications as YES, right?

deepak786 avatar Jan 10 '22 15:01 deepak786

yup, this is my finding so far - maybe if there's some troubleshooting page somewhere this might be of help to someone. otherwise feel free to close - feels like Flutter push/deep links are quite fragile and might break in some ways if you have too many plugins 🙈

vishna avatar Jan 10 '22 16:01 vishna

@vishna I was debugging this. I removed the IntercomAutoIntegratePushNotifications from Info.plist to make it the default. But I also had to add the property IntercomUniversalLinkDomains https://developers.intercom.com/installing-intercom/docs/ios-deep-linking#universal-link

So now the mobile push deep link is working fine.

But I faced a very weird issue that mobile push is received only when the app is in the background. If the app is in the foreground then mobile push is not received. This is the issue on iOS only. Do you also have the same behaviour?

deepak786 avatar Jan 25 '22 13:01 deepak786

@vishna I was debugging this. I removed the IntercomAutoIntegratePushNotifications from Info.plist to make it the default. But I also had to add the property IntercomUniversalLinkDomains https://developers.intercom.com/installing-intercom/docs/ios-deep-linking#universal-link

So now the mobile push deep link is working fine.

But I faced a very weird issue that mobile push is received only when the app is in the background. If the app is in the foreground then mobile push is not received. This is the issue on iOS only. Do you also have the same behaviour?

I guess it's expected behavior for FCM (which Intercom uses to send push notifications)

Ruslan660 avatar Feb 12 '22 15:02 Ruslan660

@deepak786 yes, currently debugging why in app messages don't show anymore @Ruslan660 intercom is not using FCM on iOS

UPDATE: doesn't seem to work after first run (login + user hash id)... but then it works 🤷

vishna avatar Jun 29 '22 10:06 vishna

hi @deepak786 , @vishna , @Ruslan660

I have same problem too but I'm using universal link.

when I added IntercomUniversalLinkDomains , it's working but then opens safari and App Store too in the same time.

i'm using FCM for deeplinks. It's working but in push-notification for iOS, i have a problem like that. How can i cancel to open safari and appstore?

Also, I don't use uni_links, I'm using firebase_dynamic_linkspackage.

KadriyeMacit avatar Aug 05 '22 09:08 KadriyeMacit

@vishna I was debugging this. I removed the IntercomAutoIntegratePushNotifications from Info.plist to make it the default. But I also had to add the property IntercomUniversalLinkDomains https://developers.intercom.com/installing-intercom/docs/ios-deep-linking#universal-link So now the mobile push deep link is working fine. But I faced a very weird issue that mobile push is received only when the app is in the background. If the app is in the foreground then mobile push is not received. This is the issue on iOS only. Do you also have the same behaviour?

I guess it's expected behavior for FCM (which Intercom uses to send push notifications)

But this flag causes the messaging window to open automatically. It shouldn't be like that, as some might need to customise it.

aprzedecki avatar Jul 18 '23 11:07 aprzedecki