我正在从parse.com迁移到城市飞艇,我差不多完成了所有工作,但一件事。当我的应用程序处于打开状态并发送推送通知时,将显示警报视图不是。如果我把应用程序的背景或接近的应用程序,我成功收到的通知。城市飞艇没有在应用程序内显示警报
我必须尝试不同的东西,使其工作,我尝试加入:
func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) {
UAirship.push().appRegisteredForRemoteNotificationsWithDeviceToken(deviceToken)
}
func application(application: UIApplication, didRegisterUserNotificationSettings notificationSettings: UIUserNotificationSettings) {
UAirship.push().appRegisteredUserNotificationSettings()
}
func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject]) {
UAirship.push().appReceivedRemoteNotification(userInfo, applicationState: application.applicationState)
}
func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject], fetchCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void) {
UAirship.push().appReceivedRemoteNotification(userInfo,
applicationState:application.applicationState,
fetchCompletionHandler:completionHandler)
}
func application(application: UIApplication, handleActionWithIdentifier identifier: String?, forRemoteNotification userInfo: [NSObject : AnyObject], completionHandler:() -> Void) {
UAirship.push().appReceivedActionWithIdentifier(identifier!,
notification: userInfo,
applicationState: application.applicationState,
completionHandler: completionHandler)
}
func application(application: UIApplication, handleActionWithIdentifier identifier: String?, forRemoteNotification userInfo: [NSObject : AnyObject], withResponseInfo responseInfo: [NSObject : AnyObject], completionHandler:() -> Void) {
UAirship.push().appReceivedActionWithIdentifier(identifier!,
notification: userInfo,
responseInfo: responseInfo,
applicationState: application.applicationState,
completionHandler: completionHandler)
}
而改变UAConfig到自动设置禁用:
let config: UAConfig = UAConfig.defaultConfig()
config.automaticSetupEnabled = false
UAirship.takeOff(config)
我也加到我的AppDelegate这样的:
class AppDelegate: UIResponder, UIApplicationDelegate, UAPushNotificationDelegate {
而且把这:
UAirship.push().userNotificationTypes = [.Alert, .Badge, .Sound]
UAirship.push().pushNotificationDelegate = self
但什么工作,我与这真的沮丧,因为我不能让它工作,为我,城市飞艇的文件,目前还不清楚这件事情。
如果我没有弄错,它应该在默认情况下工作,没有做这一切,但它没有。
我希望有人能帮助我,这是我没有所有的修改完整代码:
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
// Populate AirshipConfig.plist with your app's info from
// https://go.urbanairship.com
// or set runtime properties here.
let config: UAConfig = UAConfig.defaultConfig()
UAirship.takeOff(config)
UAirship.push().userPushNotificationsEnabled = true
// Clear badge
UAirship.push().resetBadge()
return true
}[...]}
我用斯威夫特2时,Xcode 7.2.1和iOS8上,与城市飞艇6.4.x
感谢
我错过了其他的东西,因为它仍然不能正常工作:/ – Lucas
你如何配置推送通知代理?它必须在'UAirship.takeOff(config)'之后设置。 – gatlinhebert
就是这样。我在iPhone上收到了推送,但没有显示提醒。我必须在这些方法中创建一个警报吗? – Lucas