更新到IOS 8和Xcode 6后,本地通知无法正常工作 [英] Local Notification not working since updating to IOS 8 and Xcode 6

查看:113
本文介绍了更新到IOS 8和Xcode 6后,本地通知无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

自从更新到IOS 8和Xcode 6以来,还有其他人遇到本地通知问题吗?我的应用程序运行正常, notification.firdate 是从日期选择器设置并且工作正常, notification.alertBody 表现得很好。现在我已经更新它不起作用。我添加了断点,我的被激活的值存储在其中。任何人都可以帮助我吗?

Has anyone else had problems with local notifications since updating to IOS 8 and Xcode 6? I have my application which was running fine and the notification.firdate was set from date picker and working fine, notification.alertBody showed up fine. Now i've updated it doesn't work. I've added break points and my firedate has a value stored in it. Can anyone please help me?

推荐答案

您需要更新代码才能在iOS8中接收通知。更多信息此处

You need to update your code to be able to receive notifications in iOS8. More info here.

Objective-C代码:

Objective-C code:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    if ([UIApplication instancesRespondToSelector:@selector(registerUserNotificationSettings:)]){
    [application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSound categories:nil]];
    }
    // Override point for customization after application launch.
    return YES;
}

Swift代码:

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool {
//registering for sending user various kinds of notifications
application.registerUserNotificationSettings(UIUserNotificationSettings(forTypes: UIUserNotificationType.Sound|UIUserNotificationType.Alert |UIUserNotificationType.Badge, categories: nil)   
// Override point for customization after application launch.     
return true
}

这篇关于更新到IOS 8和Xcode 6后,本地通知无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆