cmaycumber / config-plugin-react-native-intercom

Expo plugin for adding @intercom/react-native-intercom using expo config plugins
74 stars 38 forks source link

Disable Request Notification Permission #58

Open frknylmzcom2 opened 1 year ago

frknylmzcom2 commented 1 year ago

Hello, the plugin currently automatically asks for notification permission when the app is opened, can we add this to a config?

This is my current config, can we add one here like disableNotificationRegistration? Because there is already a place inside where we get notification permission. It seems like it is not user friendly to ask for notification permission as soon as the application is opened at first.

[
  'config-plugin-react-native-intercom',
    {
      androidApiKey: INTERCOM_ANDROID_API_KEY as string,
      iosApiKey: INTERCOM_IOS_API_KEY as string,
      appId: INTERCOM_APP_ID as string,
      isPushNotificationsEnabledAndroid: true,
      isPushNotificationsEnabledIOS: true,
    },
],

Thank You!

elmaxe commented 1 year ago

Are you sure this is an intercom issue and not an issue elsewhere in your code? I.e are you sure you're not calling requestNotificationPermissionsAsync on startup etc. Just making sure

eexit commented 1 year ago

Hello,

What OS are you referring to? If iOS, just remove isPushNotificationsEnabledIOS from the config, and you're good to go, you'll be able to request for the permission whenever you wish in your app.

For Android, it should not request the permission upon the app start unless you request to add a new notification channel.

Hope this helps!

frknylmzcom2 commented 1 year ago

Are you sure this is an intercom issue and not an issue elsewhere in your code? I.e are you sure you're not calling requestNotificationPermissionsAsync on startup etc. Just making sure

I don't think this is related to the intercom side, because the part that triggers the push notification permission is in the config package. Please see here;

https://github.com/cmaycumber/config-plugin-react-native-intercom/blob/e7f6033d591743c731413407c8a2a4b249027c88/packages/intercom-react-native/src/withIntercomIOS.ts#L93-L116

frknylmzcom2 commented 1 year ago

Hello,

What OS are you referring to? If iOS, just remove isPushNotificationsEnabledIOS from the config, and you're good to go, you'll be able to request for the permission whenever you wish in your app.

For Android, it should not request the permission upon the app start unless you request to add a new notification channel.

Hope this helps!

Hello, If I remove isPushNotificationsEnabledIOS, I cannot receive push notification by intercom, so when we reply to a user, if the app is not open, we want receive the push notification.

noahsettersten commented 1 year ago

I'll second the use case that @frknylmzcom2 is asking for. We want to be able to receive Intercom's push notifications on iOS in the app, but would like to disable the config plugin from asking for the permission. Then, we can ask the user for permission in our app code when it makes sense within the app instead of at launch.

We're using a solution based on the fork at https://github.com/EnhanceTech/config-plugin-react-native-intercom for now, but it would be great to have an additional option for the plugin. Perhaps something like requestPushNotificationsPermission: true/false that decides whether the config plugin adds the permission request or not.

Thanks for the work on this config plugin!

patrickomeara commented 1 year ago

I'll third the need for this feature. We have a screen explaining how notifications benefit the user that shows after login. Since implementing this AMAZING plugin, that screen has become a little confused as the permission has already been requested. We are also seeing more users deny the permission, which would be lovely to rectify.

This plugin is great, thanks for the hard work.

itajenglish commented 10 months ago

+1 any updates on this?

ucakyunus commented 10 months ago

+1 any updates on this?

ovidb commented 10 months ago

+1 on this. I've spent countless hours trying to figure out why do notifications show up at app start.

itajenglish commented 10 months ago

@patrickomeara, @ucakyunus, and @ovidb Feel free to use this patch file I created of @noahsettersten's solution.

https://gist.github.com/itajenglish/667791a5b97447f4c2ca2d5c10d54cd5

Patch Package: https://www.npmjs.com/package/patch-package

ovidb commented 10 months ago

@itajenglish do you do anything else besides this? If I do this for me Intercom doesn't seem to work anymore.

itajenglish commented 10 months ago

@itajenglish do you do anything else besides this? If I do this for me Intercom doesn't seem to work anymore.

@ovidb This is working for us. What seems to be the problem exactly?

ovidb commented 10 months ago

@itajenglish I'm now getting this error when I'm trying to send the token to Intercom

 ERROR  Invariant Violation: No callback found with cbID 11392 and callID 5696 for  IntercomModule.sendTokenToIntercom - most likely the callback was already invoked. Args: '[true]', js engine: hermes

And I'm not receiving any messages from intercom, nor can I instantiate it on my side

itajenglish commented 10 months ago

@itajenglish

I'm now getting this error when I'm trying to send the token to Intercom


 ERROR  Invariant Violation: No callback found with cbID 11392 and callID 5696 for  IntercomModule.sendTokenToIntercom - most likely the callback was already invoked. Args: '[true]', js engine: hermes

And I'm not receiving any messages from intercom, nor can I instantiate it on my side

@ovidb that's odd. Let's jump on a video call and I can help you troubleshoot https://meet.google.com/zem-rtdh-jps

ovidb commented 10 months ago

@itajenglish uhm that's new 😅.

Never had someone offer to jump on a call from a github issue. As you can imagine I didn't expect that, otherwise I would have been paying more attention here

eexit commented 10 months ago

Hello,

Could you share the solution if you found any?

Thanks.

itajenglish commented 10 months ago

Hello,

Could you share the solution if you found any?

Thanks.

Hi @eexit is the patch file not working for you?

https://github.com/cmaycumber/config-plugin-react-native-intercom/issues/58#issuecomment-1681056994

eexit commented 10 months ago

@itajenglish Aww, sorry. I thought you guys found a solution during your call. I just wanted to be sure you'd share with everyone ^^

Thanks 🙏🏻