我目前正在测试TestFlight中的应用程序并需要生产APNs证书才能测试Firebase中的通知.
我已按照此视频中的所有步骤成功配置了开发APNs证书:https://www.youtube.com/watch?v = LBw5tuTvKd4
我还检查了Firebase支持指南后的步骤.虽然我注意到Apple开发者网站自编写本指南以来略有变化:https: //firebase.google.com/docs/cloud-messaging/ios/certs#configure_an_app_id_for_push_notifications
我使用与开发证书相同的方法在developer.apple.com上生成了生产APNs证书,但是当我尝试将.p12文件上传到Firebase时,它给出了以下错误:
"证书环境不匹配.确保您获得了正确的开发或生产APNS证书."
我肯定会上传从生产APNS证书生成的.p12,我还需要为生产证书做些什么吗?
push-notification apple-push-notifications ios firebase firebase-cloud-messaging
我正在尝试为我的应用程序设置推送通知系统.我有一个服务器和开发人员许可证来设置推送通知服务.
我目前正在Swift中运行我的应用程序.我希望能够从我的服务器远程发送通知.我怎样才能做到这一点?
在我的应用中,我需要推送通知.我正在实施推送通知文档中的所有说明.但是我从推送通知中收到错误:
Fail To Register For Remote Notifications With Error:
Error Domain=NSCocoaErrorDomain Code=3000 "no valid 'aps-environment'
entitlement string found for application" UserInfo=0x2340a0
{NSLocalizedDescription=no valid 'aps-environment' entitlement string
found for application}
Run Code Online (Sandbox Code Playgroud)
我做错了什么?
在提交二进制版本后,我收到了Apple的警告邮件.
Missing Push Notification Entitlement - Your app appears to include API used to register with the Apple Push Notification service, but the app signature's entitlements do not include the "aps-environment" entitlement.
If your app uses the Apple Push Notification service, make sure your App ID is enabled for Push Notification in the Provisioning Portal, and resubmit after signing your app with a Distribution provisioning profile that includes the "aps-environment" entitlement.
See "Provisioning and Development" in the Local and Push …Run Code Online (Sandbox Code Playgroud) 到目前为止,我使用了开发推送证书,推送通知效果很好.
现在我想将我的应用程序提交给Apple,因此我创建了一个生产证书并将其设置为"代码签名身份" - >"发布"
我还将.p12文件放在我的生产服务器中.
但推动现在不起作用.
当我从xcode运行时,它是否可以工作?或者从App Store下载应用程序时它会起作用吗?如果是这样我该怎么测试呢?
我有一些相当简单的事我想做.我将一个自定义数据附加到我处理的一些推送通知中
-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
Run Code Online (Sandbox Code Playgroud)
我寻找UIApplicationLaunchOptionsRemoteNotificationKey,并且它就是它.
如果我的应用程序是第一次启动,则只会调用该方法.如果我的应用程序在通知进入后已经在后台运行并且用户按下通知上的"查看"按钮,我该如何读取相同的密钥?我想将它们发送到特定的视图控制器,并在其上打开该数据,就像我第一次从通知中启动应用程序时一样.
iOS 10引入了推送通知框架更新,
UserNotificationsUI.framework
正如在Apple docs上所写,它允许我们在用户设备上显示本地和远程通知时自定义它们的外观.
因此,如果有人知道如何在锁定屏幕上显示推送通知中的图像.像andorid推送通知一样.
谢谢,
当我的应用程序没有运行并收到推送通知时,如果我点击该通知,则启动应用程序 - 但是它不会提示用户设置的警报视图,询问他们是否要查看通知的内容与否.它只是发射,并坐在那里.
该推送通知做的工作完美的应用程序时的运行-无论是作为活跃APP或者在后台-但没有正常工作时,该应用程序是不能运行的.
我尝试注销launchOptionsNSDictionary,application: didFinishLaunchingWithOptions:看看它带来了什么负载 - 但它出现了"(null)".所以它基本上什么都没有 - 这是没有意义的,因为它不应该包含Notification的负载?
任何人都有任何想法如何在应用程序未运行时如何使Push Notifications工作?
编辑:这是我正在使用的代码,application: didReceiveRemoteNotification只是为了看看是什么:
if (UIApplicationStateBackground) {
NSLog(@"===========================");
NSLog(@"App was in BACKGROUND...");
}
else if (UIApplicationStateActive == TRUE) {
NSLog(@"===========================");
NSLog(@"App was ACTIVE");
}
else {
[[UIApplication sharedApplication] setApplicationIconBadgeNumber: 99];
UIAlertView *BOOM = [[UIAlertView alloc] initWithTitle:@"BOOM"
message:@"app was INACTIVE"
delegate:self
cancelButtonTitle:@"a-ha!"
otherButtonTitles:nil];
[BOOM show];
NSLog(@"App was NOT ACTIVE");
}
Run Code Online (Sandbox Code Playgroud)
所以这应该照顾所有应用程序的状态 - 但事实并非如此.推送通知仅在应用程序运行时有效 - 无论是在后台还是在前台......
================================================
更新/编辑#2:根据"@dianz"建议(下面),我修改了我的代码 …
我有一个非常奇怪的问题,我实施了:
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler
Run Code Online (Sandbox Code Playgroud)
用于静音远程推送通知.当应用程序处于后台并连接到Xcode时,它非常适用.当我拔下任何iOS设备并运行应用程序时,请移至后台并发送远程通知,didReceiveRemoteNotification:fetchCompletionHandler而不是被调用.
我的代码如下:
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
NSInteger pushCode = [userInfo[@"pushCode"] integerValue];
NSLog(@"Silent Push Code Notification: %i", pushCode);
NSDictionary *aps = userInfo[@"aps"];
NSString *alertMessage = aps[@"alert"];
if (pushCode == kPushCodeShowText) {
UILocalNotification *localNotif = [[UILocalNotification alloc] init];
localNotif.fireDate = [NSDate date];
localNotif.timeZone = [NSTimeZone defaultTimeZone];
localNotif.alertBody = alertMessage;
localNotif.alertAction = @"OK";
localNotif.soundName = @"sonar.aiff";
// localNotif.applicationIconBadgeNumber = 0;
localNotif.userInfo = nil;
[[UIApplication sharedApplication] presentLocalNotificationNow:localNotif];
UILocalNotification *clearNotification …Run Code Online (Sandbox Code Playgroud) debugging background objective-c apple-push-notifications ios
我正在构建一个严重依赖APN的应用程序.在我的应用程序第一次启动时,iOS会询问是否允许此应用程序使用APN(作为registerForRemoteNotificationTypes:调用的结果).然而,一旦被解雇,这个对话框永远不会弹出.我必须手动去Settings->Notifications->MyApp启用/禁用那里的东西.那么有没有办法避免这种喧嚣,并实际体验用户每次在调试模式下启动应用程序时的第一次启动体验?
iphone objective-c push-notification apple-push-notifications ios
ios ×8
iphone ×4
objective-c ×4
background ×1
debugging ×1
firebase ×1
ios10 ×1
multitasking ×1
swift ×1