我的服务器上有一个人员数据库,其中包含
group number
属性我想为每个组分别发送通知。使用以下代码,它将向所有应用程序发送通知。我如何设置或订阅应用程序,以便它知道某个手机属于某个组?每个成员在访问应用程序之前都需要先登录。
var app = {
// Application Constructor
initialize: function() {
this.bindEvents();
},
// Bind Event Listeners
//
// Bind any events that are required on startup. Common events are:
// 'load', 'deviceready', 'offline', and 'online'.
bindEvents: function() {
document.addEventListener('deviceready', this.onDeviceReady, false);
},
// deviceready Event Handler
//
// The scope of 'this' is the event. In order to call the 'receivedEvent'
// function, we must explicitly call 'app.receivedEvent(...);'
onDeviceReady: function() {
console.log('Received Device Ready Event');
console.log('calling setup push');
// Set your iOS Settings
var iosSettings = {};
iosSettings["kOSSettingsKeyAutoPrompt"] = false;
iosSettings["kOSSettingsKeyInAppLaunchURL"] = true;
window.plugins.OneSignal
.startInit("3074529d MY APP ID HERE d5eb61b000")
.handleNotificationReceived(function(jsonData) {
alert("Notification received: \n" + JSON.stringify(jsonData));
console.log('Did I receive a notification: ' + JSON.stringify(jsonData));
})
.handleNotificationOpened(function(jsonData) {
alert("Notification opened: \n" + JSON.stringify(jsonData));
console.log('didOpenRemoteNotificationCallBack: ' + JSON.stringify(jsonData));
})
.inFocusDisplaying(window.plugins.OneSignal.OSInFocusDisplayOption.InAppAlert)
.iOSSettings(iosSettings)
.endInit();
},
};