我知道有很多类似的问题,但我已经尝试过多种方法了,仍然无法通过Parse在通过Test Flight安装的应用程序上获得推送通知。
如果我通过Xcode连接我的手机并下载应用程序,那么它就可以正常工作。 但是,如果我将相同的构建上传到Testflight并尝试发送推送,什么也不会发生。
有人说有生产证书和开发者证书。或者可能是沙盒令牌。但我不确定如何解决这些问题。
我已经向Parse添加了生产和开发SSL证书。
附:我正在使用开发人员预配文件进行构建,并导出AD HOC Developer。
我的App Delegate代码是:
#import "AppDelegate.h"
#import <Parse/Parse.h>
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[Parse setApplicationId:@"----I have mine in----"
clientKey:@"----I have mine in----"];
//-- Set Notification
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
{
[[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];
[[UIApplication sharedApplication] registerForRemoteNotifications];
}
else
{
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:
(UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert)];
}
//--- your custom code
return YES;
}
- (void)application:(UIApplication *)application
didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
// Store the deviceToken in the current installation and save it to Parse.
PFInstallation *currentInstallation = [PFInstallation currentInstallation];
[currentInstallation setDeviceTokenFromData:deviceToken];
[currentInstallation saveInBackground];
}
- (void)application:(UIApplication *)application
didReceiveRemoteNotification:(NSDictionary *)userInfo {
[PFPush handlePush:userInfo];
}
如果您需要其他代码,我可以提供。如何通过Test Flight使推送通知正常工作。