-
-
Save muralitharanaspritle/149a799b2fefbad7b1be539d59ed8c32 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
import {Platform, StyleSheet, Text, View } from 'react-native'; | |
import React, {useEffect} from 'react'; | |
import messaging from '@react-native-firebase/messaging'; | |
const App = () => { | |
useEffect(() => { | |
Platform.OS === 'android' && getRegisterAndroid(); | |
getToken(); | |
}, []); | |
// this method register the android device with fcm, For ios it automatically register when the app launched | |
async function getRegisterAndroid() { | |
let isDeviceRegistered = | |
await messaging().registerDeviceForRemoteMessages(); | |
console.log('android device registered', isDeviceRegistered); | |
} | |
//both android and ios return unique device token | |
async function getToken() { | |
const token = await messaging().getToken(); | |
console.log('token', token); | |
} | |
return ( | |
<View style={{flex: 1, justifyContent: 'center', alignItems: 'center'}}> | |
<Text>Notifee</Text> | |
</View> | |
); | |
}; | |
export default App; | |
const styles = StyleSheet.create({}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment