Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Django 如何使用phonegap推送插件从pyapns获取定制负载?_Django_Cordova_Apple Push Notifications_Phonegap Pushplugin_Pyapns - Fatal编程技术网

Django 如何使用phonegap推送插件从pyapns获取定制负载?

Django 如何使用phonegap推送插件从pyapns获取定制负载?,django,cordova,apple-push-notifications,phonegap-pushplugin,pyapns,Django,Cordova,Apple Push Notifications,Phonegap Pushplugin,Pyapns,我们正在使用将推送通知从Django应用程序发送到运行phonegap应用程序的iOS设备 服务器代码如下所示: def sendNotificationAPNS(title, message, targets, eventid): apns = APNs(use_sandbox=False, cert_file='/path/to/push_cert.pem', key_file='/path/to/push_cert.pem') # Send a notificat

我们正在使用将推送通知从Django应用程序发送到运行phonegap应用程序的iOS设备

服务器代码如下所示:

def sendNotificationAPNS(title, message, targets, eventid):
    apns = APNs(use_sandbox=False, cert_file='/path/to/push_cert.pem', key_file='/path/to/push_cert.pem')

        # Send a notification
        for token_hex in targets:
            payload = Payload(alert=message, sound="default", badge=1, custom={'eventid':str(eventid)})
            apns.gateway_server.send_notification(token_hex, payload)
            print('Notification to APNS send!')

        return true
// handle APNS notifications for iOS
function onNotificationAPN(e) {
    if (e.alert) {
        console.log('APNS Notifiation recieved: ' +  e.alert);
        // showing an alert also requires the org.apache.cordova.dialogs plugin
        navigator.notification.alert(e.alert);
    }

    if (e.sound) {
        // playing a sound also requires the org.apache.cordova.media plugin
        var snd = new Media(e.sound);
        snd.play();
    }

    if (e.badge) {
        pushNotification.setApplicationIconBadgeNumber(successHandler, e.badge);
    }
    //eventid
    if(e.eventid) {
        console.log('APNS eventid: ' + e.eventid);
    }

    //custom
    if(e.custom) {
        console.log('APNS eventid: ' + e.custom.eventid);
    }
}
在移动应用程序上,Phonegap推送插件的代码如下所示:

def sendNotificationAPNS(title, message, targets, eventid):
    apns = APNs(use_sandbox=False, cert_file='/path/to/push_cert.pem', key_file='/path/to/push_cert.pem')

        # Send a notification
        for token_hex in targets:
            payload = Payload(alert=message, sound="default", badge=1, custom={'eventid':str(eventid)})
            apns.gateway_server.send_notification(token_hex, payload)
            print('Notification to APNS send!')

        return true
// handle APNS notifications for iOS
function onNotificationAPN(e) {
    if (e.alert) {
        console.log('APNS Notifiation recieved: ' +  e.alert);
        // showing an alert also requires the org.apache.cordova.dialogs plugin
        navigator.notification.alert(e.alert);
    }

    if (e.sound) {
        // playing a sound also requires the org.apache.cordova.media plugin
        var snd = new Media(e.sound);
        snd.play();
    }

    if (e.badge) {
        pushNotification.setApplicationIconBadgeNumber(successHandler, e.badge);
    }
    //eventid
    if(e.eventid) {
        console.log('APNS eventid: ' + e.eventid);
    }

    //custom
    if(e.custom) {
        console.log('APNS eventid: ' + e.custom.eventid);
    }
}
问题是:我没有为e.custom或e.eventid得到任何东西?! 要访问自定义负载,我必须更改什么

谢谢