我最近在我的 React Native 應用程式中設定了推送通知,它在 iOs 中運行良好,但在 Android 中無法彈出。這是我呼叫以觸發通知的函式。

這是我在上面配置推送通知的地方

正如我所說,它在 iOS 上運行良好,當我洗掉 channelId(我知道這是 android 所必需的)時,我收到了這條訊息......這讓我相信它以某種方式進行了配置,但沒有完全配置。

以下是我的其余組態檔:


對此的任何第二意見都會很棒!謝謝你。
uj5u.com熱心網友回復:
我想你忘了創建 chanel,你可以試試這個:
function pushNotif(){
PushNotification.createChannel(
{
channelId: "specialid", // (required)
channelName: "Special messasge", // (required)
channelDescription: "Notification for special message", // (optional) default: undefined.
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.
);
PushNotification.localNotification({
channelId:'specialid', //his must be same with channelid in createchannel
title:'hello',
message:'test message'
})
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/371249.html
