- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我正在创建一个安装在/Applications 中的越狱应用程序。无论我做什么,我似乎都无法让推送通知正常工作。
我有:
症状如下。我成功注册了 APNS 并获得了设备 token 。设备 token 已成功发送到我的服务器。我的服务器成功连接到 APNS 服务器,成功向 APNS 服务器发送推送通知,没有任何投诉,我的应用程序从未收到推送消息。它只是迷路了。无论我是使用越狱的 ios 7 设备还是越狱的 ios 8 设备进行测试都没有关系。据我所知,这两种设备都成功地为其他应用程序获取了 APNS 消息。
我已经尝试了开发者和生产设置。
越狱应用程序是否有一些我遗漏的必要步骤,而这些步骤通常是在定期注册应用程序时为您完成的?系统应用程序是否不能成为 APNS 应用程序(这看起来很奇怪)?
这是一些代码。电话端(Swift):
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool
{
if Global.OSVersion() < 800
{
application.registerForRemoteNotificationTypes(UIRemoteNotificationType.Alert
| UIRemoteNotificationType.Badge
| UIRemoteNotificationType.Sound);
}
else
{
var types: UIUserNotificationType = UIUserNotificationType.Alert
| UIUserNotificationType.Badge
| UIUserNotificationType.Sound;
var settings: UIUserNotificationSettings = UIUserNotificationSettings(forTypes: types,
categories: nil);
application.registerUserNotificationSettings(settings);
}
application.beginReceivingRemoteControlEvents();
}
func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData)
{
let bytes: [Byte] = deviceToken.getBytes();
var token: String = "";
for byte: Byte in bytes
{
token += NSString(format: "%02.2hhx", byte);
}
// code to send token to server goes here...
}
func application(application: UIApplication,
didReceiveRemoteNotification userInfo: [NSObject : AnyObject],
fetchCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void)
{
let command: String = userInfo["Command"] as String;
// code to process command goes here...
}
服务器代码(C#):
private bool SendIPhone()
{
isSent = false;
PushBroker pushBroker = new PushBroker();
try
{
pushBroker.OnChannelCreated += pushBroker_OnChannelCreated;
pushBroker.OnChannelException += pushBroker_OnChannelException;
pushBroker.OnChannelDestroyed += pushBroker_OnChannelDestroyed;
pushBroker.OnServiceException += pushBroker_OnServiceException;
pushBroker.OnNotificationFailed += pushBroker_OnNotificationFailed;
pushBroker.OnNotificationSent += pushBroker_OnNotificationSent;
pushBroker.OnNotificationRequeue += pushBroker_OnNotificationRequeue;
pushBroker.OnDeviceSubscriptionChanged += pushBroker_OnDeviceSubscriptionChanged;
pushBroker.OnDeviceSubscriptionExpired += pushBroker_OnDeviceSubscriptionExpired;
pushBroker.RegisterAppleService(new ApplePushChannelSettings(XXXConfig.APNSIsProduction,
XXXStatic.APNSCertificate,
XXXConfig.APNSPassword));
AppleNotification notification = new AppleNotification();
notification.DeviceToken = cloudToPhoneID;
notification.Payload.Alert.Body = "This is a test";
notification.Payload.Sound = "Alarm.wav";
notification.Payload.Badge = 5;
notification.Payload.CustomItems["content-available"] = new Object[] { "1" };
notification.Payload.CustomItems["Command"] = new Object[] { "TestCommand" };
pushBroker.QueueNotification(notification);
}
finally
{
pushBroker.StopAllServices(); // This will force us to wait until we have sent what's in the queue...
}
return isSent;
}
void pushBroker_OnNotificationSent(object sender, INotification notification)
{
isSent = true;
}
有很多代码我没有展示,但它们都按预期工作。 SendIPhone 始终返回 true,并且只能在调用 pushBroker_OnNotificationSent 时将其设置为 true。
权利:
<dict>
<key>application-identifier</key>
<string>REMOVEDFORPRIVACY</string>
<key>aps-environment</key>
<string>development</string>
<key>com.apple.developer.team-identifier</key>
<string>REMOVEDFORPRIVACY</string>
<key>get-task-allow</key>
<true/>
<key>keychain-access-groups</key>
<array>
<string>REMOVEDFORPRIVACY</string>
</array>
</dict>
我错过了什么或者没有从这里开始的路径?
最佳答案
我没有测试它,但如果我知道 Apple 允许在 iOS 根应用程序文件夹中推送通知(只需查看“提示”应用程序),那么证书可能有问题,所以这可能会有所帮助:
http://www.hackthatphone.com/3x/push.html
这是一个针对被黑客激活的 iOS 设备的教程,这些设备没有获得推送通知的有效证书,但它也可以帮助您。
关于ios - 用于越狱应用程序的 Apple 通知服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28415570/
我在为 MacOSX 构建的独立包中添加 DMG 背景的自定义图标时遇到问题。我在项目的根目录中添加了一个包。正在从中加载自定义图标,但没有加载 DMG 背景图标。我正在使用 Java fx 2.2.
Qt for Symbian 和 Qt for MeeGo 有什么区别?我知道 Qt 是一个交叉编译平台。这是否意味着如果我使用来自 Qt 的库,完全相同的库可以在所有支持 Qt 的设备(例如 Sym
我正在尝试使用 C# .NET 3.5/4.0 务实地运行 SQL Server 数据库的备份。我已经找到了如何完成此操作,但是我似乎找不到用于备份的命名空间库。 我正在寻找 Microsoft.Sq
我最近在疯狂学习 Java,但我通常是一名 .NET 开发人员。 (所以请原谅我的新手问题。) 在 .Net 中,我可以在不使用 IIS 的情况下开发 ASP.Net 页面,因为它有一个简化的 Web
这post仅当打印命令中有字符串时才有用。现在我有大量的源代码,其中包含一条声明,例如 print milk,butter 应该格式化为 print(milk,butter) 用\n 捕获行尾并不成功
所以我的问题是: https://gist.github.com/panSarin/4a221a0923927115584a 当我保存这个表格时,我收到了标题中的错误 NoMethodError (u
如何让 Html5 音频在点击时播放声音? (ogg 用于 Firefox 等浏览器,mp3 用于 chrome 等浏览器) 到目前为止,我可以通过 onclick 更改为单个文件类型,但我无法像在普
如果it1和it2有什么区别? std::set s; auto it1 = std::inserter(s, s.begin()); auto it2 = std::inserter(s, s.en
4.0.0 com.amkit myapp SpringMVCFirst
我目前使用 Eclipse 作为其他语言的 IDE,而且我习惯于不必离开 IDE 做任何事情 - 但是我真的很难为纯 ECMAScript-262 找到相同或类似的设置。 澄清一下,我不是在寻找 DO
我想将带有字符串数组的C# 结构发送到C++ 函数,该函数接受void * 作为c# 结构和char** 作为c# 结构字符串数组成员。 我能够将结构发送到 c++ 函数,但问题是,无法从 c++ 函
我正在使用动态创建的链接: 我想为f:param附加自定义转换器,以从#{name}等中删除空格。 但是f:param中没有转换器
是否可以利用Redis为.NET创建后写或直写式缓存?理想情况下,透明的高速缓存是由单个进程写入的,并且支持从数据库加载丢失的数据,并每隔一段时间持久保存脏块? 我已经搜查了好几个小时,也许是goog
我正在通过bash执行命令的ssh脚本。 FILENAMES=( "export_production_20200604.tgz" "export_production_log_2020060
我需要一个正则表达式来出现 0 到 7 个字母或 0 到 7 个数字。 例如:匹配:1234、asdbs 不匹配:123456789、absbsafsfsf、asf12 我尝试了([a-zA-Z]{0
我有一个用于会计期间的表格,该表格具有期间结束和开始的开始日期和结束日期。我使用此表来确定何时发生服务交易以及何时在查询中收集收入,例如... SELECT p.PeriodID, p.FiscalY
我很难为只接受字符或数字的 Laravel 构建正则表达式验证。它是这样的: 你好<-好的 123 <- 好的 你好123 <-不行 我现在的正则表达式是这样的:[A-Za-z]|[0-9]。 reg
您实际上会在 Repeater 上使用 OnItemDataBound 做什么? 最佳答案 “此事件为您提供在客户端显示数据项之前访问数据项的最后机会。引发此事件后,数据项将被清空,不再可用。” ~
我有一个 fragment 工作正常的项目,我正在使用 jeremyfeinstein 的 actionbarsherlock 和滑动菜单, 一切正常,但是当我想自定义左侧抽屉列表单元格时,出现异常
最近几天,我似乎平均分配时间在构建我的第一个应用程序和在这里发布问题!! 这是我的第一个应用程序,也是我们的设计师完成的第一个应用程序。我试图满足他所做的事情的外观和感觉,但我认为他没有做适当的事情。
我是一名优秀的程序员,十分优秀!