Hello
First please understand me my English is rather poor.
I have a issue for using Expo Push Notification.
In expo app, expo push notification work well.
But when I build android standalone app and install on my device, then doesn’t work.
It doesn’t get expopushnotificationtoken, that is, getExpoPushTokenAsync() does not get expo push notification token.
First it doesn’t get token but few days after it get token although code is not changed. But next day it doesn’t work again.
Following is my code:
if (!Expo.Constants.isDevice) {
return;
}
let { 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;
}
try {
let value = await Notifications.getExpoPushTokenAsync();
alert(value);
// Send this to a server
} catch (error) {
alert(error);
}
Notifications.getExpoPushTokenAsync() function doesn’t return anything. So alert(value) doesn’t work.
my app.json file is following:
{
“expo”: {
“name”: “neighborhood”,
“description”: “This project is really great.”,
“slug”: “neighborhood”,
“privacy”: “public”,
“sdkVersion”: “30.0.0”,
“platforms”: [“ios”, “android”],
“version”: “1.0.0”,
“orientation”: “portrait”,
“icon”: “./src/assets/images/icon.png”,
“notification”: {
“icon”: “./src/assets/images/notification_icon.png”,
“color”: “#000000”
},
“updates”: {
“fallbackToCacheTimeout”: 0
},
“assetBundlePatterns”: [
“**/*”
],
“ios”: {
“supportsTablet”: true,
“bundleIdentifier”: “com.waterflower.safteyzone3”
},
"android": {
"package": "com.waterflower.safteyzone",
"googleServicesFile": "./google-services.json"
}
}
}
my react native information is following:
Environment:
OS: macOS High Sierra 10.13.4
Node: 10.11.0
Yarn: Not Found
npm: 6.4.1
Watchman: 4.9.0
Xcode: Xcode 9.4 Build version 9F1027a
Android Studio: 3.1 AI-173.4720617
Packages: (wanted => installed)
react: 16.3.1 => 16.3.1
react-native: https://github.com/expo/react-native/archive/sdk-30.0.0.tar.gz => 0.55.4
my expo version 2.2.4(expo --version).
I’m very happy to hear your advance.
Thanks.