iOS Push notifications not working on for ad hoc distributions with Test Flight

我的未来我决定 提交于 2020-01-12 14:50:19

问题


Having a bit of a weird issue...

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]];    
}

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

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...

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?

Update

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.


回答1:


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!).



来源:https://stackoverflow.com/questions/10640942/ios-push-notifications-not-working-on-for-ad-hoc-distributions-with-test-flight

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!