import { Platform } from "react-native" ; import Constants from "expo-constants" ; import * as Permissions from "expo-permissions" ; import * as Notifications from "expo-notifications" ; export const registerForPushNotifications = async ( ) => { if ( Constants . isDevice ) { const { status : existingStatus } = await Permissions . getAsync ( Permissions . NOTIFICATIONS ) ; let finalStatus = existingStatus ; if ( existingStatus !== "granted" ) { const { status } = await Permissions . askAsync ( Permissions . NOTIFICATIONS ) ; finalStatus = status ; } if ( finalStatus !== "granted" ) { return ; } return ( await Notifications . getExpoPushTokenAsync ( ) ) . data ; } if ( Platform . OS === "android" ) { Notifications . setNotificationChannelAsync ( "default" , { name : "default" , importance : Notifications . AndroidImportance . MAX , vibrationPattern : [ 0 , 250 , 250 , 250 ] , lightColor : "#FF231F7C" } ) ; } } ;