将Parse推送通知集成到Xcode 7项目(Swift)

时间:2015-09-28 02:45:39

标签: ios parse-platform apple-push-notifications swift2

我正在将Parse Push通知集成到一个应用程序中,并且已经陷入了Swift 2.0转换。 代码是:

if application.respondsToSelector("registerUserNotificationSettings:") {
            let userNotificationTypes: UIUserNotificationType = [.Alert, .Badge, .Sound]
            let settings = UIUserNotificationSettings(forTypes: userNotificationTypes, categories: nil)
            application.registerUserNotificationSettings(settings)
            application.registerForRemoteNotifications()
        } else {
            let types: UIUserNotificationType = [.Badge, .Alert, .Sound]
            application.registerForRemoteNotificationTypes(types)
        }

Xcode抱怨“无法将'UIUserNotificationType'类型的值转换为预期的参数类型'UIRemoteNotificationType'

3 个答案:

答案 0 :(得分:6)

尝试以下代码,因为不推荐使用UIRemoteNotification,请使用registerUserNotificationSettigns设置通知设置。但请记住在Apple的成员中心和解析时配置推送通知,以便它可以工作。您可以按照本教程从步骤1到步骤4,这很棒。 https://www.parse.com/tutorials/ios-push-notifications

if application.respondsToSelector("registerUserNotificationSettings:") {
   let settings = UIUserNotificationSettings(forTypes: [.Alert, .Badge, .Sound], categories: nil)
   application.registerUserNotificationSettings(settings)
   application.registerForRemoteNotifications()
}

答案 1 :(得分:3)

尝试以下代码,但Xcode仍然显示在iOS 8.0中不推荐使用UIRemoteNotificationType的警告

let types : UIRemoteNotificationType = [.Badge, .Alert, .Sound]
application.registerForRemoteNotificationTypes(types)

答案 2 :(得分:2)

试试这段代码......

app delegate.swift

<div class="row" >
        <div class="twevle columns"><h1>Test Footer</h1></div>
</div>
<?php //get_footer(); ?>