我正在使用以下插件 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.0 phonegap -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/
在选择我想要运行操作的频率时,唯一的选项是“每天”、“每小时”和“每10分钟”。谢谢!我想为我的Rails3.1应用程序运行调度程序。 最佳答案 这不是一个优雅的解决方案,但您可以安排它每天运行,并在实际开始工作之前检查日期是否为当月的第一天。 关于ruby-如何每月在Heroku运行一次Scheduler插件?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/8692687/
我对最新版本的Rails有疑问。我创建了一个新应用程序(railsnewMyProject),但我没有脚本/生成,只有脚本/rails,当我输入ruby./script/railsgeneratepluginmy_plugin"Couldnotfindgeneratorplugin.".你知道如何生成插件模板吗?没有这个命令可以创建插件吗?PS:我正在使用Rails3.2.1和ruby1.8.7[universal-darwin11.0] 最佳答案 随着Rails3.2.0的发布,插件生成器已经被移除。查看变更日志here.现在
我在Rails工作并有以下类(class):classPlayer当我运行时bundleexecrailsconsole然后尝试:a=Player.new("me",5.0,"UCLA")我回来了:=>#我不知道为什么Player对象不会在这里初始化。关于可能导致此问题的操作/解释的任何建议?谢谢,马里奥格 最佳答案 havenoideawhythePlayerobjectwouldn'tbeinitializedhere它没有初始化很简单,因为你还没有初始化它!您已经覆盖了ActiveRecord::Base初始化方法,但您没有调
这里有一个很好的答案解释了如何在Ruby中下载文件而不将其加载到内存中:https://stackoverflow.com/a/29743394/4852737require'open-uri'download=open('http://example.com/image.png')IO.copy_stream(download,'~/image.png')我如何验证下载文件的IO.copy_stream调用是否真的成功——这意味着下载的文件与我打算下载的文件完全相同,而不是下载一半的损坏文件?documentation说IO.copy_stream返回它复制的字节数,但是当我还没有下
我正在尝试解析一个文本文件,该文件每行包含可变数量的单词和数字,如下所示:foo4.500bar3.001.33foobar如何读取由空格而不是换行符分隔的文件?有什么方法可以设置File("file.txt").foreach方法以使用空格而不是换行符作为分隔符? 最佳答案 接受的答案将slurp文件,这可能是大文本文件的问题。更好的解决方案是IO.foreach.它是惯用的,将按字符流式传输文件:File.foreach(filename,""){|string|putsstring}包含“thisisanexample”结果的
1.错误信息:Errorresponsefromdaemon:Gethttps://registry-1.docker.io/v2/:net/http:requestcanceledwhilewaitingforconnection(Client.Timeoutexceededwhileawaitingheaders)或者:Errorresponsefromdaemon:Gethttps://registry-1.docker.io/v2/:net/http:TLShandshaketimeout2.报错原因:docker使用的镜像网址默认为国外,下载容易超时,需要修改成国内镜像地址(首先阿里
作为新的阿里云用户,您可以50免费试用多种优惠,价值高达1,700美元(或8,500美元)。这将让您了解和体验阿里云平台上提供的一系列产品和服务。如果您以个人身份注册免费试用,您将获得价值1,700美元的优惠。但是,如果您是注册公司,您可以选择企业免费试用,提交基本信息通过企业实名注册验证,即可开始价值$8,500的免费试用!本教程介绍了如何设置您的帐户并使用您的免费试用版。关于免费试用在我们开始此试用之前,您还必须遵守以下条款和条件才能访问您的免费试用:只有在一年内创建的账户才有资格获得阿里云免费试用。通过此免费试用优惠,用户可以免费试用免费试用活动页面上列出的每种产品一次。如果您有多个帐
您认为可以作为插件很好地存在于您的Rails应用程序中必须实现的哪些行为?您过去曾搜索过哪些插件功能但找不到?哪些现有的Rails插件可以改进或扩展,如何改进或扩展? 最佳答案 我希望在管理界面中看到一个引擎插件,它提供了应用程序中所有模型的仪表板摘要,以及可配置的事件图表。 关于ruby-on-rails-您希望看到哪些Rails插件?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questio
我在我的项目中有一个用户和一个管理员角色。我使用Devise创建了身份验证。在我的管理员角色中,我没有任何确认。在我的用户模型中,我有以下内容:devise:database_authenticatable,:confirmable,:recoverable,:rememberable,:trackable,:validatable,:timeoutable,:registerable#Setupaccessible(orprotected)attributesforyourmodelattr_accessible:email,:username,:prename,:surname,:
print"Enteryourpassword:"pass=STDIN.noecho(&:gets)puts"Yourpasswordis#{pass}!"输出:Enteryourpassword:input.rb:2:in`':undefinedmethod`noecho'for#>(NoMethodError) 最佳答案 一开始require'io/console'后来的Ruby1.9.3 关于ruby-为什么不能使用类IO的实例方法noecho?,我们在StackOverflow上