Page MenuHomePhabricator

[native] refresh device token after receiving message from Tunnelbroker
ClosedPublic

Authored by kamil on Jul 29 2024, 4:08 AM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Sep 10, 8:23 AM
Unknown Object (File)
Tue, Sep 10, 2:49 AM
Unknown Object (File)
Mon, Sep 9, 4:01 AM
Unknown Object (File)
Mon, Sep 9, 12:36 AM
Unknown Object (File)
Sat, Sep 7, 1:45 PM
Unknown Object (File)
Sat, Sep 7, 1:45 PM
Unknown Object (File)
Sat, Sep 7, 1:45 PM
Unknown Object (File)
Fri, Sep 6, 8:13 PM
Subscribers

Details

Summary

ENG-8498.

This is similar to the keyserver's BAD_DEVICE_TOKEN logic.

This is only about localToken which is set for every user, not touching tunnelbrokerToken so it shouldn't affect devices without CSAT and TB connection.

Depends on D12912

Test Plan

Make Tunnelbroker throw an error with an invalid device token, and test that a new token is uploaded (value in DDB changed). Additionally verified this using logs.

Diff Detail

Repository
rCOMM Comm
Branch
final-stack-3
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

kamil held this revision as a draft.
kamil published this revision for review.Aug 1 2024, 1:42 AM
kamil edited the summary of this revision. (Show Details)
kamil edited the test plan for this revision. (Show Details)
kamil edited the summary of this revision. (Show Details)
native/push/push-handler.react.js
445–459

Nit: might be best to handle the simple case first and reduce indentation a bit

if (!this.props.loggedIn) {
  return;
}
if (Platform.OS === 'android') {
  await this.ensureAndroidPushNotifsEnabled();
  return;
}
if (Platform.OS !== 'ios') {
  // should not happen... we could consider an invariant here instead
  return;
}
let missingDeviceToken = !this.props.localToken;
if (!missingDeviceToken) {
  for (const keyserverID in this.props.deviceTokens) {
    const deviceToken = this.props.deviceTokens[keyserverID];
    if (deviceToken === null || deviceToken === undefined) {
      missingDeviceToken = true;
      break;
    }
  }
}
await requestIOSPushPermissions(missingDeviceToken);
This revision is now accepted and ready to land.Aug 2 2024, 1:42 AM