9
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【iOS】【Urban AirShip】任意のタイミングでPUSH通知の許可設定ダイアログの表示させる

Posted at

Urban AirShipの公式ドキュメント通りにすると、↓のようになる。

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    // Override point for customization after application launch.
    let config = UAConfig.defaultConfig()
    UAirship.takeOff(config)
    UAirship.push().userNotificationTypes = ([.Alert, .Badge, .Sound])
    UAirship.push().userPushNotificationsEnabled = true
    return true
}

これを takeoff はapplication didFinishLaunchingWithOptionsのままで
userNotificationTypes 等は表示させたいビューに記載する

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    // Override point for customization after application launch.
    let config = UAConfig.defaultConfig()
    UAirship.takeOff(config)
    return true
}
// 表示させたいビューコントローラ
UAirship.push().userNotificationTypes = ([.Alert, .Badge, .Sound])
UAirship.push().userPushNotificationsEnabled = true

表示タイミングによってプッシュ通知の許諾率がかなり変わってくるので、見せ方、タイミングはかなり重要である

9
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?