阅读PhoneGap中的OneSignal通知标题

时间:2016-10-07 10:34:58

标签: javascript android json cordova onesignal

我使用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

1 个答案:

答案 0 :(得分:2)

您可以通过在jsonData.payload.title功能中调用didReceiveRemoteNotificationCallBack来获取该信息。有关完整的属性列表,请参阅Onesignal的NotificationReceivedHandler文档。