本文介绍了iOS 推送通知不适用于 Test Flight 的临时分发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

遇到一个奇怪的问题...

Having a bit of a weird issue...

在我的 AppDelegate.m 中,我有以下内容:

In my AppDelegate.m I have the following:

-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackTranslucent animated:NO];
    // Override point for customization after application launch.


    // Enable test flight reporting; https://testflightapp.com/sdk/doc/0.8.3/
    [TestFlight takeOff:@"myTestFlightToken"];

    // Let the device know we want to receive push notifications
    [[UIApplication sharedApplication] registerForRemoteNotificationTypes:
     (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];

    return YES;
}

-(void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken
{
    NSString *tokenAsString = [[deviceToken description]
                                 stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"<>"]];

    NSLog(@"Device token: %@", deviceToken);
    User.currentUserPushNotificationToken = tokenAsString;
    [TestFlight passCheckpoint: [NSString stringWithFormat: @"Registered for remote notifications %@", deviceToken]];
}

-(void)application:(UIApplication*)application didFailToRegisterForRemoteNotificationsWithError:(NSError*)error
{
    NSLog(@"Failed to get token, error: %@", error);
    [TestFlight passCheckpoint: [NSString stringWithFormat: @"Failed to register for remote notifications %@", error]];
}

我的团队正在使用 Test Flight 在开发人员和利益相关者之间分发临时构建.

My team are using Test Flight to distribute ad hoc builds between the developers and stakeholders.

当我在自己的 iPhone 4 上构建应用程序时,应用程序会询问我是否希望允许推送通知,并且该应用程序也会出现在设置">通知">通知中心"中

When I build the app on my own iPhone 4 the App asks me if I wish to allow push notifications and the app also appears in Settings > Notifications > In Notification Center

到目前为止,一切都很好...

So far, so good...

当我创建一个开发 ipa 并将其分发给团队时,不会询问其他用户是否希望允许推送通知,这也不会出现在设置 > 通知中...

When I create a development ipa and distribute this amongst the team, the other users are not asked if they wish to allow Push Notifications and this doesn't appear in Settings > Notifications...

有人能想到为什么会这样吗?

Can anybody think of why this may be?

对于分发,我正在使用 Team Provisioning Profile 构建应用程序,其中捆绑包 ID 为*"而不是应用程序名称 - 这可能是问题吗?这是 Apple 自动生成的 Team Provisioning Profile.

For distribution, I'm building the app using the Team Provisioning Profile which has an "*" for the bundle ID instead of the app name - could this be the issue? This is the Team Provisioning Profile that Apple generates automatically.

推荐答案

是的,就是这个问题.推送通知的应用标识符中不能包含通配符(否则它会推送到所有应用!).

Yes that is the issue. You cannot have a wildcard character in an app identifier for push notification (otherwise it would push to all apps!).

这篇关于iOS 推送通知不适用于 Test Flight 的临时分发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 09:29