本地通知无法工作,因为更新到IOS 8和Xcode 6
自从更新到IOS 8和Xcode 6之后,有没有其他人遇到本地通知问题? 我有我的应用程序运行良好, notification.firdate
设置从dateselect器和工作正常, notification.alertBody
显示正常。 现在我已经更新它不起作用。 我已经添加了中断点,并且已经存储了一个值。 谁能帮帮我吗?
您需要更新您的代码才能在iOS8中接收通知。 更多信息在这里 。
Objective-C代码:
- (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 }
为了接收本地NSNotification,请按照以下步骤操作:
-
将代码添加到
didFinishLaunchingWithOptions
方法中的appDelegate.h
中if ([UIApplication instancesRespondToSelector:@selector(registerUserNotificationSettings:)]){ [application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSound categories:nil]]; }
- 在swift中,Self.Type不能直接转换为扩展名为Objective-c类的AnyClass
- 用户界面命令在IBAction中跳过
- 无法从另一个类访问NSString – Objective-c
- Sqlite查询,比较date时间字段与当前的date时间
- 使用MonoTouch.CoreText在特定的坐标上绘制文本片段
- 强制整个屏幕上的横向方向MPMoviePlayerController在退出全屏时阻止正确的旋转
- 圆球上的两个点之间的圆柱方向,Scenekit,四元数IOS
- 如何比较两个给定的时间与当前时间?
- 当我在我的xcode项目中使用#include <OpenGL / gl.h>时,它在哪里查找gl.h文件?