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

fix(ios): handle nil messaging token #3790

Merged
merged 2 commits into from
Jun 18, 2020
Merged

fix(ios): handle nil messaging token #3790

merged 2 commits into from
Jun 18, 2020

Conversation

TPXP
Copy link
Contributor

@TPXP TPXP commented Jun 16, 2020

Description

On iOS, calling [FIRInstanceID instanceID] deleteIDWithHandler causes a crash. I quite like this method since it enables me to drop all tokens generated until now, and make sure we won't send any more messages to this device (use case: user logout).

Related issues

Not reported.

Release Summary

[messaging] Fixed a crash if the fetched token is null (typically when deleting the cloud messaging instance).

Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
    • Yes
  • My change supports the following platforms;
    • iOS
  • My change includes tests: NO (but maybe it should!)
    • e2e tests added or updated in packages/\*\*/e2e
    • jest tests added or updated in packages/\*\*/__tests__
  • I have updated TypeScript types that are affected by my change.
  • This is a breaking change;
    • Yes
    • No

Test Plan

You can try to call [FIRInstanceID instanceID] deleteIDWithHandler in your app code (exposing it as a JS API would be welcome by the way!).

Thanks a lot for this project!

This happens when `[FIRInstanceID instanceID] deleteIDWithHandler` is called (useful for dropping all previously generated tokens, e.g. when a user logs out).
@CLAassistant
Copy link

CLAassistant commented Jun 16, 2020

CLA assistant check
All committers have signed the CLA.

@TPXP TPXP changed the title FIX: Don't crash if the FCM is reset to null FIX: Don't crash if the FCM toke is reset to null Jun 16, 2020
@TPXP TPXP changed the title FIX: Don't crash if the FCM toke is reset to null FIX: Don't crash if the FCM token is reset to null Jun 16, 2020
@Salakar
Copy link
Member

Salakar commented Jun 17, 2020

Re the JS api, its already available through the Instance ID package: https://rnfirebase.io/reference/iid#delete

@Salakar
Copy link
Member

Salakar commented Jun 17, 2020

LGTM if this fixes a crash. Though one minor point; should we not be sending null tokens to JS so you know when a token has been invalidated? I think Android sends null - the JS SDK Web types don't really indicate what should happen here and is just typed as any 🙈

EDIT: shipped, 'fix it in post' as they say if this should actually emit nulls

@Salakar Salakar changed the title FIX: Don't crash if the FCM token is reset to null fix(ios): handle nil messaging token Jun 17, 2020
@Salakar Salakar merged commit b2ffe11 into invertase:master Jun 18, 2020
hmhm2292 pushed a commit to hmhm2292/react-native-firebase that referenced this pull request Jul 13, 2021
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.

4 participants