Hi there,
I am using Expo Push Notification and it works well with the Expo app both in the Android emulator as well as on my device (LG Q6, Android 7.1.1). However, when I build the standalone Android app with…
exp build:android
… and install it on my device, I am not prompted for the push notification permission and the permission request comes back with “granted”. I also receive a proper Expo Push Token. As said, it works absolutely perfect when running from the Expo App.
/* registers application to allow push notifications */
static async registerPush(){
var result = "";
var pushGranted = true;
let permissionResult = await Permissions.getAsync(Permissions.NOTIFICATIONS);
if(permissionResult.status !== 'granted'){
/* permission does not yet exist */
alert("Please allow push messages.");
let decisionResult = await Permissions.askAsync(Permissions.NOTIFICATIONS);
if(decisionResult.status !== 'granted'){
pushGranted = false;
}
}
if (pushGranted == true) {
result = await Notifications.getExpoPushTokenAsync();
}
return result;
}
When I install the app on my Android 7.1.1 LG Q6 phone and fire up push notifications with the API using Postman, then the first request comes back ok, but I do not see any push notification (App is in foreground).
REQUEST:
{
"to": "ExponentPushToken[XXXXXXXXXXX]",
"title": "You has messages",
"body": "Something new just arrived"
}
RESPONSE:
{
"data": {
"status": "ok"
}
}
Any request I make to the API afterwards fails with “DeviceNotRegistered” error code, although I send it through exactly as with the Expo App and exactly as with the first try.
REQUEST:
{
"to": "ExponentPushToken[XXXXXXXXXXX]",
"title": "Another try",
"body": "Second message arrived"
}
RESULT:
{
"data": {
"status": "error",
"message": "SNS failed to send the notification (reason: EndpointDisabled, status code: 400).",
"details": {
"error": "DeviceNotRegistered",
"sns": {
"statusCode": 400,
"reason": "EndpointDisabled",
"__message": "Endpoint is disabled"
}
}
}
}
I really tried several ways, spent quite some time here in the forum, but could not really find the root cause of my issue. Further I have no idea, why I am not being asked for permission by the standalone app.
Many thanks in advance for your help!
Jan