0

I have setup the expo push notification in my app. I am able to get the device token for both android and ios in my expo go app. when i publish my app to test-flight i am able to get the device token as well. But when i publish the app to PLaystore for testing i notice the device token is not working because i am saving the token to my laravel backend.

below is my code

const registerForPushNotificationsAsync = async () => {

let token;

if (Device.isDevice) {

const { status: existingStatus } =
  await Notifications.getPermissionsAsync();
let finalStatus = existingStatus;

if (existingStatus !== "granted") {
  
  const { status } = await Notifications.requestPermissionsAsync();
  finalStatus = status;
}
if (finalStatus !== "granted") {

  alert("Failed to get push token for push notification!");
  return;
}

token = (await Notifications.getExpoPushTokenAsync()).data;

sendDeviceTokenToBackend(token)

} else {

alert("Must use physical device for Push Notifications");

}

if (Platform.OS === "android") { Notifications.setNotificationChannelAsync("default", { name: "default", importance: Notifications.AndroidImportance.MAX, vibrationPattern: [0, 250, 250, 250], lightColor: "#FF231F7C", }); }

return token; };

Below is the code i use to send to my backend

const sendDeviceTokenToBackend=(token)={
  const obj = {
     device_token: data,
  };
  const response = await db.communicate(
   "POST",
   "/device/tokens",
   obj,
    "auth"
   );
 }

i read a couple of answers on stackoverflow that i need to configure FCM in order for my android noticifation to work. but here i will be using php sdk for my notification configuration so i am saving the device token to the backend. so i have a few questions

  1. if i am to use firebase to save my device token how will i send my device token to my php backend from firebase .
  2. since i will be managing it on my php server instead of expo push notification how do i get the token in andriod when i publish it to playstore any help on this i will appreciate
prof lord
  • 1
  • 4

0 Answers0