通过TestFlight使用Parse推送通知

5

我知道有很多类似的问题,但我已经尝试过多种方法了,仍然无法通过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使推送通知正常工作。

我没有什么可以帮助你的补充,但我也遇到了同样的问题,想知道你是否已经解决了它? - Gareth Jeanne
1个回答

5
我来回答自己的问题: 您的配置文件必须包含用于生产/分发的推送证书(仍然必须是开发人员配置文件)。 由于TestFlight在生产级别上运行,因此仅使用开发人员推送证书无法正常工作(需同时添加两者)。 如有其他问题,请随时询问。我经历了很多烦恼排查。

我现在也遇到了同样的问题,但对于TestFlight中的推送工作并不太担心。只要它们在从Xcode直接下载后在我的测试设备上工作,那么在发布到应用商店时它们应该能正常工作,对吗? - Melly
直接从xCode和应用商店下载会有所不同。我相信iTunes Connect Test Flight可以让你更好地了解它在应用商店中的表现。 - huddie96
你的项目构建设置中的“代码签名”和“配置文件”是什么样子的?你能展示一下截图吗?谢谢! - Van Du Tran
另外,我猜你不是在谈论苹果的Testflight吧?你成功地让它与苹果的Testflight配合工作了吗? - Van Du Tran
我在新的Apple测试飞行中没有任何使用推送通知的应用程序。如果您愿意,可以在stackOverflow上创建一个带有图像和代码的问题,说明您的设置,并且我会查看它并尝试找出问题所在。将链接发布在此处。PS.请确保模糊掉包含个人信息的图像部分(您可以使用预览应用程序来完成)。 - huddie96

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接