leegeunhyeok / react-native-zendesk-messaging

🗣️ Zendesk messaging SDK for React Native
https://www.npmjs.com/package/react-native-zendesk-messaging
MIT License
40 stars 12 forks source link

iOS push notifications #50

Closed deelo55 closed 1 month ago

deelo55 commented 3 months ago

In the push notification instructions I'm not 100% clear but is this suggesting you need to modify the native code to get push notifications working?

stale[bot] commented 2 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

adilsaeed31 commented 2 months ago

@deelo55 Yes, you have to configure the notification into the native code in IOS, especially in order for it to work. After configuring, the notification will only work in the Production release.

deelo55 commented 2 months ago

@adilsaeed31 Is there a way to do this when using Expo without writing any native code? For example, in Expo I can get the push token, and then call this to update Zendesk: https://github.com/leegeunhyeok/react-native-zendesk-messaging/blob/master/docs/apis.md#updatepushnotificationtoken

adilsaeed31 commented 2 months ago

Yes, you can do this functionality in the Expo, if you don't want to use native code, then try firebase/messaging, there is a code I'll share below with that you can get the Push Notifications in both platforms, but android for sure, in IOS I'm not 100% sure for the Expo. But if you have a bare react native project then you have to add the native code to the IOS side to get the notifications in the production release version app only.

import * as Zendesk from "react-native-zendesk-messaging"

messaging().onMessage(async (remoteMessage) => {
      console.log(
        'A new message arrived! ',
     remoteMessage
      )

      const responsibility = await Zendesk.handleNotification(
        remoteMessage.data,
      )

      switch (responsibility) {
        case 'MESSAGING_SHOULD_DISPLAY':
        case 'MESSAGING_SHOULD_NOT_DISPLAY':
          // remote message was handled by Zendesk SDK
          return

        case 'NOT_FROM_MESSAGING':
        default:
          break
      }
     } 
stale[bot] commented 1 month ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.