Skip to content

Instantly share code, notes, and snippets.

@muralitharanaspritle
Created May 4, 2023 16:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save muralitharanaspritle/149a799b2fefbad7b1be539d59ed8c32 to your computer and use it in GitHub Desktop.
Save muralitharanaspritle/149a799b2fefbad7b1be539d59ed8c32 to your computer and use it in GitHub Desktop.
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