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

feat: fetch currently stored device token using JS method #216

Merged
merged 12 commits into from
Nov 1, 2023

Conversation

ami-aman
Copy link
Collaborator

@ami-aman ami-aman commented Nov 1, 2023

Closes: https://github.com/customerio/issues/issues/11181

Provides a feature to fetch currently stored device token and returns as a string in a promise. This feature helps getting device tokens for FCM & APN for iOS and FCM token for Android. The following is the use case of the feature:

   CustomerIO.pushMessaging()
      .getRegisteredDeviceToken()
      .then((token) => {
        setDeviceToken(token);
      })
      .catch((error) => {
        console.log(error);
   });

How to test this feature?

  • Open the Sample app.
  • Go to the Settings screen.
  • Look at the very first field, which is labeled Device token.
  • If the app has generated a device token, you will see it in this field. Otherwise, the field will be blank.

@ami-aman ami-aman requested a review from a team November 1, 2023 10:50
Copy link
Contributor

@Shahroz16 Shahroz16 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good and tested as well.

@ami-aman ami-aman merged commit 482f780 into main Nov 1, 2023
6 checks passed
@ami-aman ami-aman deleted the aman/getDeviceToken branch November 1, 2023 13:11
github-actions bot pushed a commit that referenced this pull request Nov 1, 2023
## [3.3.0](3.2.1...3.3.0) (2023-11-01)

### Features

* fetch currently stored device token using JS method ([#216](#216)) ([482f780](482f780))
Comment on lines +128 to +132
if (deviceToken != null) {
promise.resolve(deviceToken)
} else {
promise.reject("device_token_not_found", "The device token is not available.")
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would have preferred to have the Promise resolve null instead of reject when the native device token is null.

A device not yet having a device token is not an error, IMO.

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