1
我的遠程推送通知出現在應用程序之外,但不在應用程序中。通知不會出現在應用程序
這就是我如何配置我的應用程序委託,就像你在didRecieveRemoteNotification中看到的,我配置了一個警報出現,這在動物園內顯得很好,但我不想要一個警告框,我想要一個頂級橫幅一個應用程序外:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
var type = UIUserNotificationType.Badge | UIUserNotificationType.Alert | UIUserNotificationType.Sound;
var setting = UIUserNotificationSettings(forTypes: type, categories: nil);
UIApplication.sharedApplication().registerUserNotificationSettings(setting);
UIApplication.sharedApplication().registerForRemoteNotifications();
return true
}
func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject]) {
println("Recived: \(userInfo)")
//Parsing userinfo:
var temp : NSDictionary = userInfo
if let info = userInfo["aps"] as? Dictionary<String, AnyObject>
{
var alertMsg = info["alert"] as! String
var alert: UIAlertView!
alert = UIAlertView(title: "", message: alertMsg, delegate: nil, cancelButtonTitle: "OK")
alert.show()
}
}
您需要發佈一個本地通知,而不是一個警報視圖,如果這是你想要 – Paulw11
我加入這didrecieveremotenotification VAR localNotification經驗:UILocalNotification = UILocalNotification() localNotification.alertAction =「Glimp」 localNotification.fireDate =的NSDate (timeIntervalSinceNow:0) localNotification.alertBody = alertMsg localNotification.soundName = UILocalNotificationDefaultSoundName; localNotification.timeZone = NSTimeZone(name:「Default」) UIApplication.sharedApplication()。scheduleLocalNotification(localNotification) – MasterWizard