按照Urban Airship网站上的广泛启动指南,我完成了。完成后,我在我的手机上运行应用程序,它运行正常,控制台充满了Urban Airship的东西,一切都符合计划,但后来我注意到使用推送通知的请求永远不会出现。 目前,我在 AppDelegate.m 中运行以下代码:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
//[[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:0.22 green:0.24 blue:0.75 alpha:1]];
[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"Color"] forBarMetrics:UIBarMetricsDefault];
//NSShadow *shadow = [[NSShadow alloc] init];
//shadow.shadowColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.8];
//shadow.shadowOffset = CGSizeMake(0, 1);
[[UINavigationBar appearance] setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys: [UIColor colorWithRed:1 green:1 blue:1 alpha:1.0], NSForegroundColorAttributeName, [UIFont fontWithName:@"HelveticaNeue-CondensedBlack" size:21.0], NSFontAttributeName, nil]];
UAConfig *config = [UAConfig defaultConfig];
[UAirship takeOff:config];
[UAPush shared].notificationTypes = (UIRemoteNotificationTypeBadge |
UIRemoteNotificationTypeSound |
UIRemoteNotificationTypeAlert |
UIRemoteNotificationTypeNewsstandContentAvailability);
[UAPush setDefaultPushEnabledValue:YES];
return YES;
}
是的,我已正确导入 UAirship.h 等,所以请不要提示。
CONSOLE: 我知道生产密钥不是有效的,但那是因为您需要一张信用卡才能注册,而且我正在等待监护人的信用卡通过。
2014-06-26 02:13:13.504 Husky Athletics[573:83549] [W] -[UAConfig validate] [Line 160] Production App Key is not valid.
2014-06-26 02:13:13.506 Husky Athletics[573:83549] [W] -[UAConfig validate] [Line 164] Production App Secret is not valid.
2014-06-26 02:13:13.506 Husky Athletics[573:83549] [I] +[UAirship executeUnsafeTakeOff:] [Line 147] App Key: (censored)
2014-06-26 02:13:13.506 Husky Athletics[573:83549] [I] +[UAirship executeUnsafeTakeOff:] [Line 148] App Secret: (censored)
2014-06-26 02:13:13.507 Husky Athletics[573:83549] [I] +[UAirship executeUnsafeTakeOff:] [Line 149] Server: https://device-api.urbanairship.com
2014-06-26 02:13:13.508 Husky Athletics[573:83549] [D] -[UAirship configureUserAgent] [Line 314] Setting User-Agent for UA requests to Husky Athletics 1.0 (iPhone; iPhone OS 8.0; UALib 4.0.0; (censored); en_US)
2014-06-26 02:13:13.541 Husky Athletics[573:83549] [D] void PrintReachabilityFlags(SCNetworkReachabilityFlags, const char *) [Line 79] Reachability Flag Status: WR t----l- networkStatusForFlags
2014-06-26 02:13:13.545 Husky Athletics[573:83549] [I] +[UAirship executeUnsafeTakeOff:] [Line 193] Registering UAURLProtocol
2014-06-26 02:13:13.555 Husky Athletics[573:83549] Channel ID: (censored)
2014-06-26 02:13:14.269 Husky Athletics[573:83549] [D] -[UAUserAPIClient updateUser:deviceToken:channelID:onSuccess:onFailure:] [Line 117] Updating user (censored).
2014-06-26 02:13:14.274 Husky Athletics[573:83549] [E] -[UAAppDelegate application:didFailToRegisterForRemoteNotificationsWithError:] [Line 42] Failed To Register For Remote Notifications With Error: Error Domain=NSCocoaErrorDomain Code=3000 "no valid 'aps-environment' entitlement string found for application" UserInfo=0x170074e40 {NSLocalizedDescription=no valid 'aps-environment' entitlement string found for application}
2014-06-26 02:13:14.589 Husky Athletics[573:83549] [D] __20-[UAUser updateUser]_block_invoke161 [Line 290] Failed to update user
2014-06-26 02:13:28.614 Husky Athletics[573:83821] [D] +[UAKeychainUtils getDeviceID] [Line 238] Retrieved device id info from keychain.
2014-06-26 02:13:28.615 Husky Athletics[573:83821] [D] +[UAKeychainUtils getDeviceID] [Line 245] Loaded Device ID: (censored)
2014-06-26 02:13:28.616 Husky Athletics[573:83821] [D] +[UAKeychainUtils getDeviceID] [Line 246] Loaded Model Name: iPhone6,1
2014-06-26 02:13:29.004 Husky Athletics[573:83549] [D] __39-[UAAnalytics sendOperationWithEvents:]_block_invoke [Line 582] Analytics data sent successfully. Status: 200