本地通知不适用于某些用户(iOS 8) [英] Local notifications not working for some users (iOS 8)
问题描述
我有一个使用本地通知的应用程序,而且以前版本中的ti工作正常。我已经更新了iOS 8的应用程序并进行了测试并且运行良好。在向app store提交更新后,少数用户抱怨他们没有收到任何本地通知。但是,我检查过的大量用户都很好,并且没有发现任何问题。
I have an app which uses local notifications and ti used to work fine in previous versions. I have updated the app for iOS 8 and tested and worked fine. After submitting the update to app store, a small number of users are complaining that they don't get any local notifications. However, a larger number of users that I've checked are fine and don't observe any issues.
对于有错误的用户(至少其中一个),他们无法在设置 - > myApp屏幕中看到通知项目;缺少整个选项而不是禁用它。 位置和使用蜂窝数据在该屏幕中,但不在通知中。我试图更改设置 - >通知 - > myApp下的设置,它按预期工作。
For the users with the error (at least one of them), they can not see the "Notifications" item in the "Settings->myApp" screen; The whole option is missing not that it is disabled. "Location" and "Use Cellular Data" are in that screen but not the Notifications. I have tried to change the settings under "Settings->Notifications->myApp" and it work as expected.
有关如何调试此问题的任何建议都会非常有用。谢谢!
Any suggestions for how to debug this issue would be very helpful. Thanks!
推荐答案
尝试使用Objective-C:
Try this for Objective-C:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions: (NSDictionary *)launchOptions
{
// are you running on iOS8?
if ([application respondsToSelector:@selector(registerUserNotificationSettings:)])
{
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeBadge|UIUserNotificationTypeAlert|UIUserNotificationTypeSound) categories:nil];
[application registerUserNotificationSettings:settings];
}
else // iOS 7 or earlier
{
UIRemoteNotificationType myTypes = UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound;
[application registerForRemoteNotificationTypes:myTypes];
}
}
对于Swift:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool {
// Override point for customization after application launch.
if(UIApplication.instancesRespondToSelector(Selector("registerUserNotificationSettings:")))
{
application.registerUserNotificationSettings(UIUserNotificationSettings(forTypes: UIUserNotificationType.Sound | UIUserNotificationType.Alert | UIUserNotificationType.Badge, categories: nil))
}
else
{
//
}
return true
}
这篇关于本地通知不适用于某些用户(iOS 8)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!