且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

本地通知不工作的设备,但是在模拟器工作

更新时间:2023-10-20 23:01:04

我看到你正在使用的Objective-C。考虑到这个问题,有人问一年前,你可能不是想通了这一点,或者你正在使用雨燕2.0​​现在。我有同样的问题,我能够通过添加以下code。与雨燕2.0​​来解决它。

I see that you're using Objective-C. Considering this question was asked a year ago, you've probably either figured this out or you're using Swift 2.0 now. I had the same issue and I was able to resolve it with Swift 2.0 by adding the following code.

AppDelegate.swift

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    // Override point for customization after application launch.

    application.registerUserNotificationSettings(UIUserNotificationSettings(forTypes: [.Alert, .Badge, .Sound], categories: nil))
    application.beginBackgroundTaskWithName("showNotification", expirationHandler: nil)

    return true
}

您可以看到我的完整的答案here.

You can see my full answer here.