gpt4 book ai didi

react-native-push-notification - 本地通知不适用于 Android

转载 作者:行者123 更新时间:2023-12-04 01:06:25 25 4
gpt4 key购买 nike

有人可以让我知道我哪里出错了。
从我在 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?
});
};

最佳答案

您创建了 channel 吗?
似乎您需要创建一个才能使其工作。
https://github.com/zo0r/react-native-push-notification#channel-management-android
要使用 channel ,请在启动时创建它们并将匹配的 channelId 传递给 PushNotification.localNotification 或 PushNotification.localNotificationSchedule。

PushNotification.createChannel(
{
channelId: "channel-id", // (required)
channelName: "My channel", // (required)
channelDescription: "A channel to categorise your notifications", // (optional) default: undefined.
playSound: false, // (optional) default: true
soundName: "default", // (optional) See `soundName` parameter of `localNotification` function
importance: 4, // (optional) default: 4. Int value of the Android notification importance
vibrate: true, // (optional) default: true. Creates the default vibration patten if true.
},
(created) => console.log(`createChannel returned '${created}'`) // (optional) callback returns whether the channel was created, false means it already existed.
);

关于react-native-push-notification - 本地通知不适用于 Android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66299182/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com