【发布时间】:2021-02-21 04:36:23
【问题描述】:
谁能告诉我我哪里出错了。
从我在instructions 上看到的内容来看,如果您只使用本地通知并使用自动链接,则不需要对Android 特定文件进行修改......除了将googlePlayServicesVersion = "<Your play services version>" // default: "+" 添加到android/build.gradle....和<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/> 加上<uses-permission android:name="android.permission.VIBRATE" /> 到AndroidManifest.xml
下面是我的主要源码
PushNotification.configure({
// (optional) Called when Token is generated (iOS and Android)
onRegister: function(token) {
console.log('onRegister token:', token);
},
// (required) Called when a remote is received or opened, or local notification is opened
onNotification: function(notification) {
console.log('onNotification:', notification);
notification.finish(PushNotificationIOS.FetchResult.NoData);
},
// Should the initial notification be popped automatically
popInitialNotification: true,
requestPermissions: true,
});
userNowInactive = () => {
this.showNotification();
}
showNotification = () => {
PushNotification.localNotification({
//ios and android properties
title: 'Face2Face: Beacon Timer Expired',
message: 'Perhaps set your beacon timer for another hour?',
playSound: true,
soundName: 'sound.mp3',
//android only properties
channelId: 'your-channel-id',
autoCancel: true,
// largeIcon: 'ic_launcher',
// smallIcon: 'ic_launcher',
bigText: 'Face2Face: Beacon Timer Expired',
subText: 'Perhaps set your beacon timer for another hour?',
vibrate: true,
vibration: 300,
priority: 'high',
//ios only properties...is there any?
});
};
【问题讨论】:
-
我可以查看整个代码文件吗?
标签: react-native react-native-android react-native-push-notification