【发布时间】:2019-08-26 11:58:20
【问题描述】:
我在“react-native-push-notification”库的帮助下将推送通知集成到本机反应中。推送来自节点 js(后端)。 我在 Android 和 IOS 环境中都成功推送。
现在我有两个问题 1)在ios中,当我收到推送时,通知有效负载“userInteraction”中有一个参数。此参数用于该用户是否单击通知。现在它在 android 中运行良好,但在 ios 中这总是错误的。 2)我想在推送通知中设置自定义图像,这是来自推送。
我正在使用“https://www.npmjs.com/package/react-native-push-notification”这个库。
我试过这段代码:-
export function setupPushNotification(handleNotification) {
PushNotification.configure({
onRegister: function (token) {
if (Platform.OS == 'ios') {
firebase.messaging().getToken().then((token) => {
alert(JSON.stringify(token))
requestaddAuthToke(token)
.then((data) => {
console.log("hello2 " + JSON.stringify(data))
})
.catch((error) => {
console.log("hello3 " + JSON.stringify(error.message));
})
});
}
else {
console.log("hello2 " + JSON.stringify(token.token))
requestaddAuthToke(token.token)
.then((data) => {
console.log("hello2 " + JSON.stringify(data))
})
.catch((error) => {
console.log("hello3 " + JSON.stringify(error.message));
})
}
},
onNotification: function (notification) {
const clicked = notification.userInteraction;
if (clicked)
handleNotification(notification.episodeCode)
if (Platform.OS == 'ios')
notification.finish(PushNotificationIOS.FetchResult.NoData);
},
senderID: "529815244511",
permissions: {
alert: true,
badge: true,
sound: true
},
popInitialNotification: true,
requestPermissions: true,
})
return PushNotification
}
我们将不胜感激任何类型的帮助。
【问题讨论】:
标签: android ios firebase react-native push-notification