プッシュ通知のためのParse.comチュートリアルの後、私は自分のアプリケーションのdidFinishLaunchingWithOptionsメソッドにこのスウィフトコードを置く:Parse.com UIRemoteNotificationType非推奨
:私はこれらの2回の警告を取得しています'UIRemoteNotificationType' was deprecated in iOS version 8.0: Use UIUserNotificationType for user notifications and registerForRemoteNotifications for receiving remote notifications instead.
'registerForRemoteNotificationsTypes' was deprecated in iOS version 8.0: Please use registerForRemoteNotifications and registerUserNotificationSettings: instead
// Register for Push Notitications
if application.applicationState != UIApplicationState.Background {
// Track an app open here if we launch with a push, unless
// "content_available" was used to trigger a background push (introduced in iOS 7).
// In that case, we skip tracking here to avoid double counting the app-open.
let preBackgroundPush = !application.respondsToSelector("backgroundRefreshStatus")
let oldPushHandlerOnly = !self.respondsToSelector("application:didReceiveRemoteNotification:fetchCompletionHandler:")
var pushPayload = false
if let options = launchOptions {
pushPayload = options[UIApplicationLaunchOptionsRemoteNotificationKey] != nil
}
if (preBackgroundPush || oldPushHandlerOnly || pushPayload) {
PFAnalytics.trackAppOpenedWithLaunchOptions(launchOptions)
}
}
if application.respondsToSelector("registerUserNotificationSettings:") {
let userNotificationTypes = UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound
let settings = UIUserNotificationSettings(forTypes: userNotificationTypes, categories: nil)
application.registerUserNotificationSettings(settings)
application.registerForRemoteNotifications()
} else {
let types = UIRemoteNotificationType.Badge | UIRemoteNotificationType.Alert | UIRemoteNotificationType.Sound
application.registerForRemoteNotificationTypes(types)
}
私は単にそれが私に言っているものを交換することはできますか?
ありがとう:ここ
スイフト2.0例です。私はiOS 7をターゲットにする必要はありません。そこで、最後の数行を次のように置き換えました。else { let types = UIUserNotificationType.Badge | UIUserNotificationType.Alert | UIUserNotificationType.Sound application.registerForRemoteNotifications(types) } 'エラーが発生しました:タイプUIUserNotificationTypeの引数リストでregisterForRemoteNotificationsを呼び出せません – jordangrogan
私はそれを取得しません。 'registerForRemoteNotifications()'を実行しているあなたのiOS8バージョンでは、どのタイプも渡していません。どのようなタイプの登録が必要かをどのように知っていますか? – Honey