Please provide the following:
- SDK Version: 40.0.0
- Platforms(Android/iOS/web/all): Andriod
It works fine through expo app, then once its a build and installed on my device it fails to get a token and run the .then() function after so i can connect to my chat. my code, possibly important its an installed apk not published to the store
import * as Permissions from 'expo-permissions';
import * as Notifications from 'expo-notifications';
useEffect(() => {
registerForPushNotificationsAsync().then(token => {
socket.emit("connectAdmin", {
pas: 'super secret pass',
token
})
});
}, []);
async function registerForPushNotificationsAsync() {
let token;
if (Constants.isDevice) {
const { status } = await Permissions.getAsync(Permissions.NOTIFICATIONS);
let finalStatus = status;
if (finalStatus !== 'granted') {
const { status } = await Permissions.askAsync(Permissions.NOTIFICATIONS);
finalStatus = status;
}
if (finalStatus !== 'granted') {
alert('Notifications turned off please turn on in App settings to be notified of new messages!');
}
token = (await Notifications.getExpoPushTokenAsync()).data;
} 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;
}
standard copy and paste
Here’s the catlog of when i open the app from my pixel,
2021-01-21 18:10:46.065 2246-2384/? D/j: WARNING: getPackageName called on ScopedContext
2021-01-21 18:10:46.126 2246-2383/? I/ReactNativeJS: granted
2021-01-21 18:10:46.133 2246-2384/? W/System.err: java.lang.reflect.InvocationTargetException
2021-01-21 18:10:46.133 2246-2384/? W/System.err: at java.lang.reflect.Method.invoke(Native Method)
2021-01-21 18:10:46.133 2246-2384/? W/System.err: at l.d.b.c.invokeExportedMethod(ExportedModule.java:8)
2021-01-21 18:10:46.133 2246-2384/? W/System.err: at org.unimodules.adapters.react.NativeModulesProxy.callMethod(NativeModulesProxy.java:7)
2021-01-21 18:10:46.133 2246-2384/? W/System.err: at java.lang.reflect.Method.invoke(Native Method)
2021-01-21 18:10:46.133 2246-2384/? W/System.err: at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:18)
2021-01-21 18:10:46.133 2246-2384/? W/System.err: at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:2)
2021-01-21 18:10:46.133 2246-2384/? W/System.err: at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
2021-01-21 18:10:46.133 2246-2384/? W/System.err: at android.os.Handler.handleCallback(Handler.java:938)
2021-01-21 18:10:46.133 2246-2384/? W/System.err: at android.os.Handler.dispatchMessage(Handler.java:99)
2021-01-21 18:10:46.133 2246-2384/? W/System.err: at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:1)
2021-01-21 18:10:46.133 2246-2384/? W/System.err: at android.os.Looper.loop(Looper.java:223)
2021-01-21 18:10:46.133 2246-2384/? W/System.err: at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:8)
2021-01-21 18:10:46.133 2246-2384/? W/System.err: at java.lang.Thread.run(Thread.java:923)
2021-01-21 18:10:46.142 2246-2384/? W/System.err: Caused by: java.lang.IllegalArgumentException: Please set your project ID. A valid Firebase project ID is required to communicate with Firebase server APIs: It identifies your project with Google.
2021-01-21 18:10:46.142 2246-2384/? W/System.err: at com.google.android.gms.common.internal.q.h(com.google.android.gms:play-services-basement@@17.3.0:2)
2021-01-21 18:10:46.142 2246-2384/? W/System.err: at com.google.firebase.iid.FirebaseInstanceId.f(com.google.firebase:firebase-iid@@20.2.3:2)
2021-01-21 18:10:46.142 2246-2384/? W/System.err: at com.google.firebase.iid.FirebaseInstanceId.getInstance(com.google.firebase:firebase-iid@@20.2.3:1)
2021-01-21 18:10:46.142 2246-2384/? W/System.err: at com.google.firebase.iid.FirebaseInstanceId.l(com.google.firebase:firebase-iid@@20.2.3:1)
2021-01-21 18:10:46.142 2246-2384/? W/System.err: at expo.modules.notifications.tokens.PushTokenModule.getDevicePushTokenAsync(PushTokenModule.java:1)
2021-01-21 18:10:46.142 2246-2384/? W/System.err: ... 13 more
2021-01-21 18:10:46.229 2246-2295/? D/b: Loaded exp.host status page.
2021-01-21 18:10:47.190 2246-2260/? W/System: A resource failed to call close.
2021-01-21 18:10:47.440 1008-1079/? D/VSC: @ 9942.606: [WO] tilt angle 49