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

Expose setPushToken method to react-native lib #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

vincent-paing
Copy link

In one of my particular use-case, we refresh the token dynamically (expire and refresh token) from react native side of our app. We currently do this by having our own custom react native bridge to call respective function in native sdk. I was thinking it would be nice to have this function exposed by the library itself so others with similar use case con consume the API easily.

I also believe this adds make it easy for those using multiple push sdk in the app.

  • Added java test
  • Added Android & iOS implementation of setPushToken
  • Updated doc link to 8.0x

@billmote
Copy link
Contributor

Couple of things:

  1. The plugin is not currently built with 8.x so the doc should still point to 7.x
  2. Setting the push token would be done in the native receiver/service and can be done with MarketingCloudSdk.requestSdk { it.pushMessageManager.setPushToken() } /* something like that */. What would be the benefit of adding a javascript bridge for this?

@vincent-paing
Copy link
Author

vincent-paing commented Feb 23, 2022

Will update the doc link.

What would be the benefit of adding a javascript bridge for this?

In a case where you are developing react-native apps which have multiple push sdk (or) you want to refresh the token manually, we won't have to use a native bridge to execute setPushToken. In our case, we expire the token whenever a user log out and regenerate on logging in. We do these on react native side of the app. However, since our app has 2 push sdk, sometimes sfmc doesn't update token automatically. So, we have to create our own native bridge to call setPushToken. With this changes, one can consume the API directly from react native.

@billmote
Copy link
Contributor

That's reasonable. I will discuss this change with Product.

This allows the react-native consumer to set the token dynamically
which is useful when it has multiple push sdk or consumer refresh
token regularly
@ghost
Copy link

ghost commented Jul 12, 2022

Hello, another reason here is if you are supporting only single device sign on. It means that customer can have our application on multiple devices but is able to sign in only to one of them (last one), each time needs to do device rebinding. In this scenario we need to invalidate old token because customer may not uninstall application from old device.

If we have no way to set device key / delete it from cloud then what happens is that when we send push notification it will arrive on all devices instead of last one. I would hope if we could call setTokenDevice(null) it would deregister the old device token

@rkaartikeyan
Copy link

@billmote is there any ETA to have this PR merged? I am working in a project for a client who are using SFMC and MobilePush, we really need this setPushToken feature from RN.

Since the library doesn't have RN event listener for receive Push Notification info in react native, we supposed to use another 3rd party library, while using that library for receive PN in react native, we need to set the push token from react native.

Please consider this is an important request. Thanks.

@rkaartikeyan
Copy link

@vincent-paing can you please resolve the conflicts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants