gpt4 book ai didi

ios - PhoneGap 推送插件未在 iOS 上注册

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:00:44 24 4
gpt4 key购买 nike

我正在使用以下插件 https://github.com/phonegap/phonegap-plugin-push使用我的 phonegap 应用程序。在注册事件中我没有得到关于 iOS 版本的任何信息。在 Android 上它 100% 有效。我请求帮助,看看我是否遗漏了什么。代码如下。我有证书并启用了推送服务。我创建了一个分发证书,应用程序在 apple store 上。基本上在启动时我有一个自调用功能并通过 http 将注册发送到我们的服务器,我们没有从 ios 获得任何东西。我们使用 phonegapbuild 构建 ios 版本并通过 macincloud.com 上传。我在这里阅读了一些帖子,但没有一个能解决我的问题。

<gap:plugin name="phonegap-plugin-push" source="npm" >
<param name="SENDER_ID" value="15971xxxxxxx" />
</gap:plugin>

我的环境是 window 10 Cordova -v 6.0.0phonegap -v 5.5.0推送插件-v 1.5.3

这是代码

(function() {
'use strict';
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
var samplePushApp = angular.module('samplePushApp');
samplePushApp.factory('deviceService', deviceService);

deviceService.$inject = ['$http', '$q', '$cordovaDevice', 'messagesSqlLiteService'];

function deviceService($http, $q, $cordovaDevice, messagesSqlLiteService) {
var url = 'http://example.com/api/device/';
console.log("PushNotification Registration");
var push = PushNotification.init({
"android": {"senderID": "15971xxxxxxx"},
"ios": {"alert": "true", "badge": "true", "sound": "true"},
"windows": {} } );

push.on('registration', function(data) {
console.log(data.registrationId);
console.log("data.registrationId");
var model = $cordovaDevice.getModel();
var platform = $cordovaDevice.getPlatform();
var uuID = $cordovaDevice.getUUID();
var version = $cordovaDevice.getVersion();
var data = { "model": model, "platform": platform, "registrationId": data.registrationId, "DeviceId": uuID , "version ": version };
console.log(JSON.stringify(data));
$http.post(
url,
JSON.stringify(data),
{
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
}
}
).success(function() {
console.log("Device Info submitted");
}).error(function(data, status) {
console.error('Device Info error', status, data);
});
});

push.on('notification', function(data) {
navigator.notification.alert(data.title+" Message: " + data.message, function(){}, "", "");
messagesSqlLiteService.insert(data);
location.href = '#messages';
});

push.on('error', function(e) {
console.log(e.message);
});
}

// create an injector
var $injector = angular.injector(['samplePushApp']);
$injector.invoke(deviceService);


}
})();

已解决

作为更新。事实证明,代码没有任何问题。有两个主要问题。

我最终借了一台 mac(来自 macincloud)并用

构建了项目
phonegap build ios

第一个问题:我得到了这个错误

Build Error
===========
ld: '/Users/user000516/Downloads/my-app - ioS/platforms/ios/samplePush/Plugins/phonegap-plugin-push/GCM/Libraries/libGGLCloudMessaging.a(GGLContext+CloudMessaging.o)' does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

这意味着推送插件无法在启用位码的情况下进行编译。我在 xCode 中禁用了位码并且项目构建成功。我不确定这是否是 Phonegap Build 构建失败的原因。

第二个问题:我在 XCode 中做的另一件事是获取功能选项卡并启用推送通知功能。

在这些更改之后,代码按预期工作。

希望这对某人有帮助

最佳答案

不确定我是应该编辑我的问题还是提供解决方案作为答案。

已解决

作为更新。事实证明,代码没有任何问题。有两个主要问题。

我最终借了一台 mac(来自 macincloud)并用它构建了项目

phonegap build ios

第一个问题:我得到了这个错误

构建错误

ld: '/Users/user000516/Downloads/my-app -          ioS/platforms/ios/samplePush/Plugins/phonegap-plugin-push/GCM/Libraries/libGGLCloudMessaging.a(GGLContext+CloudMessaging.o)' does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode   for this target. for architecture arm64

clang:错误:链接器命令失败,退出代码为 1(使用 -v 查看调用)

这意味着推送插件无法在启用位码的情况下进行编译。我在 xCode 中禁用了位码并且项目构建成功。我不确定这是否是 Phonegap Build 构建失败的原因。

第二个问题:我在 XCode 中做的另一件事是获取功能选项卡并启用推送通知功能。

在这些更改之后,代码按预期工作。

希望这对某人有帮助

关于ios - PhoneGap 推送插件未在 iOS 上注册,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37024853/

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