gpt4 book ai didi

ios - phonegap 构建通用推送插件 - 没有有效的 aps 环境

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:45:19 25 4
gpt4 key购买 nike

我正在尝试为我的应用程序使用通用推送。它适用于 android 但在 ios 上我收到错误消息:没有有效的 aps-environment

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

我的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>

最佳答案

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

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

关于ios - phonegap 构建通用推送插件 - 没有有效的 aps 环境,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14677760/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com