我使用PhoneGap Build和OneSignal。 如何在PhoneGap项目中阅读通知标题。 有我的代码
......
receivedEvent: function(id) {
var iosSettings = {};
iosSettings["kOSSettingsKeyAutoPrompt"] = true;
iosSettings["kOSSettingsKeyInAppLaunchURL"] = false;
window.plugins.OneSignal.startInit( "*************************", "************")
.handleNotificationReceived(didReceiveRemoteNotificationCallBack)
.handleNotificationOpened(didOpenRemoteNotificationCallBack)
.inFocusDisplaying(window.plugins.OneSignal.OSInFocusDisplayOption.None)
.iOSSettings(iosSettings)
.endInit();
}
};
function didReceiveRemoteNotificationCallBack(jsonData) {
alert('RECEIVE: ' + JSON.stringify(jsonData));
}
function didOpenRemoteNotificationCallBack (jsonData) {
alert('OPEN: ' + JSON.stringify(jsonData));
}
app.initialize();
通知收到后如何获得TITLE? 我找到了一份文件,但我不明白 https://documentation.onesignal.com/docs/phonegap-sdk#section-receiving-notifications
答案 0 :(得分:2)
您可以通过在jsonData.payload.title
功能中调用didReceiveRemoteNotificationCallBack
来获取该信息。有关完整的属性列表,请参阅Onesignal的NotificationReceivedHandler文档。