phonegap build通用推送插件 - 没有有效的aps环境

时间:2013-02-03 21:54:59

标签: ios cordova push-notification

我试图使用通用推送我的应用程序。它适用于Android但在ios上我得到错误消息:没有有效的aps-environment

  1. 我已添加支持在Apple配置中推送通知 简介
  2. 我在启用推送
  3. 后创建并下载了配置文件
  4. 我在mobileprovision中有<key>aps-environment</key>
  5. 我已在手机上安装了移动设备和应用
  6. 我检查并测试了每个解决方案
  7. 我的config.xml

            <?xml version="1.0" encoding="UTF-8" ?>
        <widget xmlns = "http://www.w3.org/ns/widgets"
            xmlns:gap = "http://phonegap.com/ns/1.0"
            id        = "---.-------.-----"
            versionCode="10" 
            version   = "1.1.0">
    
        <!-- versionCode is optional and Android only -->
    
        <name>PhoneGap push Example</name>
    
        <description>
            An example for phonegap build docs. 
        </description>
    
       <author href="http://-----------" email="---------------">------</author>
    <access origin="*" />
    
    <!--DEVICE FEATURES ACCESS--> 
    <feature name="http://api.phonegap.com/1.0/camera"/>
    <feature name="http://api.phonegap.com/1.0/file"/>
    <feature name="http://api.phonegap.com/1.0/geolocation"/>
    <feature name="http://api.phonegap.com/1.0/media"/>
    <feature name="http://api.phonegap.com/1.0/network"/>
    <feature name="http://api.phonegap.com/1.0/notification"/>
    
    <gap:plugin name="GenericPush" /> <!-- latest release -->
    </widget>
    

    我的js

        <script type="text/javascript" charset="utf-8" src="phonegap.js"></script>
        <script type="text/javascript" charset="utf-8" src="jquery_1.5.2.min.js"></script>
        <script type="text/javascript" src="PushNotification.js"></script>
    
        <script type="text/javascript">
            var pushNotification;         
            function onDeviceReady() {
                $("#app-status-ul").append('<li>deviceready event received</li>');
    
                pushNotification = window.plugins.pushNotification;
                if (device.platform == 'android' || device.platform == 'Android') {
                    pushNotification.register(successHandler, errorHandler, {"senderID":"661780372179","ecb":"onNotificationGCM"});
                } else {
                    pushNotification.register(tokenHandler, errorHandler, {"badge":"true","sound":"true","alert":"true","ecb":"onNotificationAPN"});
                }
            }
    
            // handle APNS notifications for iOS
            function onNotificationAPN(event) {
                if (event.alert) {
                    $("#app-status-ul").append('<li>push-notification: ' + event.alert + '</li>');
                    navigator.notification.alert(event.alert);
                }
    
                if (event.sound) {
                    var snd = new Media(event.sound);
                    snd.play();
                }
    
                if (event.badge) {
                    pushNotification.setApplicationIconBadgeNumber(successHandler, event.badge);
                }
            }
    
            // handle GCM notifications for Android
            function onNotificationGCM(e) {
                $("#app-status-ul").append('<li>EVENT -> RECEIVED:' + e.event + '</li>');
    
                switch( e.event )
                {
                    case 'registered':
                    if ( e.regid.length > 0 )
                    {
                        $("#app-status-ul").append('<li>REGISTERED -> REGID:' + e.regid + "</li>");
                        // Your GCM push server needs to know the regID before it can push to this device
                        // here is where you might want to send it the regID for later use.
                        console.log("regID = " + regID);
                    }
                    break;
    
                    case 'message':
                    $("#app-status-ul").append('<li>MESSAGE -> MSG: ' + e.message + '</li>');
                    $("#app-status-ul").append('<li>MESSAGE -> MSGCNT: ' + e.msgcnt + '</li>');
                    break;
    
                    case 'error':
                    $("#app-status-ul").append('<li>ERROR -> MSG:' + e.msg + '</li>');
                    break;
    
                    default:
                    $("#app-status-ul").append('<li>EVENT -> Unknown, an event was received and we do not know what it is</li>');
                    break;
                }
            }
    
            function tokenHandler (result) {
                $("#app-status-ul").append('<li>token: '+ result +'</li>');
                // Your iOS push server needs to know the token before it can push to this device
                // here is where you might want to send it the token for later use.
            }
    
            function successHandler (result) {
                $("#app-status-ul").append('<li>success:'+ result +'</li>');
            }
    
            function errorHandler (error) {
                $("#app-status-ul").append('<li>error:'+ error +'</li>');
            }
    
            document.addEventListener('deviceready', onDeviceReady, true);
    
         </script>
    
        <div id="app-status-div">
            <ul id="app-status-ul">
                <li>Cordova PushNotification Plugin Demo</li>
            </ul>
        </div>
    

2 个答案:

答案 0 :(得分:1)

根据Phonegap Build社区论坛,您需要使用分发条款证书才能使APS注册工作:http://community.phonegap.com/nitobi/topics/ios_problem_with_push_notification_plugin_for_phonegap_build

有些人在切换到生产证书后成功了。 但是,我遇到了同样的问题,仍然无法使用生产证书。

答案 1 :(得分:0)

经过长时间的研究和反复试验。我发现我需要使用: 在IOS(adhoc供应配置文件)和推送服务器(生产aps证书和密钥)上