xcode iOS 推送通知不适用于 Test Flight 的临时分发
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10640942/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
iOS Push notifications not working on for ad hoc distributions with Test Flight
提问by bodacious
Having a bit of a weird issue...
遇到一个奇怪的问题...
In my AppDelegate.m I have the following:
在我的 AppDelegate.m 中,我有以下内容:
-(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 Flightto distribute ad hoc builds between the developers and stakeholders.
我的团队正在使用Test Flight在开发人员和利益相关者之间分发临时构建。
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
当我在自己的 iPhone 4 上构建该应用程序时,该应用程序会询问我是否希望允许推送通知,并且该应用程序还会出现在“设置”>“通知”>“通知中心”中
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...
当我创建开发 ipa 并将其分发给团队时,不会询问其他用户是否希望允许推送通知,并且这不会出现在“设置”>“通知”中...
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.
对于分发,我正在使用 Team Provisioning Profile 构建应用程序,其中捆绑 ID 带有“*”而不是应用程序名称 - 这可能是问题吗?这是 Apple 自动生成的 Team Provisioning Profile。
采纳答案by MGA
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!).
是的,就是这个问题。您不能在推送通知的应用程序标识符中使用通配符(否则它会推送到所有应用程序!)。