Created
September 2, 2021 15:14
-
-
Save warodri-sendbird/e772c5f8f490e09d0c4f9e77f095f112 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const login = user => { | |
AsyncStorage.setItem(savedUserKey, JSON.stringify(user)) | |
.then(async () => { | |
try { | |
setCurrentUser(user); | |
const authorizationStatus = await messaging().requestPermission(); | |
if ( | |
authorizationStatus === messaging.AuthorizationStatus.AUTHORIZED || | |
authorizationStatus === messaging.AuthorizationStatus.PROVISIONAL | |
) { | |
if (Platform.OS === 'ios') { | |
const token = await messaging().getAPNSToken(); | |
await sendbird.registerAPNSPushTokenForCurrentUser(token); | |
} else { | |
const token = await messaging().getToken(); | |
await sendbird.registerGCMPushTokenForCurrentUser(token); | |
} | |
} | |
} catch (err) { | |
console.error(err); | |
} | |
}) | |
.catch(err => console.error(err)); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment