Mik*_*sya 9 notifications ios ios8
我有一个使用本地通知的应用程序,并且在以前的版本中使用了ti.我已经更新了iOS 8的应用程序并进行了测试并且运行良好.在向app store提交更新后,少数用户抱怨他们没有收到任何本地通知.但是,我检查过的用户数量较多,没有任何问题.
对于有错误的用户(至少其中一个),他们无法在"设置 - > myApp"屏幕中看到"通知"项目; 缺少整个选项而不是禁用它."位置"和"使用蜂窝数据"在该屏幕中,但不在通知中.我试图更改"设置 - >通知 - > myApp"下的设置,它按预期工作.
有关如何调试此问题的任何建议都将非常有用.谢谢!
试试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];
}
}
Run Code Online (Sandbox Code Playgroud)
对于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
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2598 次 |
| 最近记录: |