func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// 註冊一個通知 通知換控制器 “新特性”
NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(switchRootViewController), name: SwitchRootViewControllerKey, object: nil)
// 註冊 Cloud
setCloud(launchOptions)
//建立window
window = windowNew()
//註冊 通知APNs
registerForPushNotifications(application)
return true
}
//註冊 通知APNs
func registerForPushNotifications(application: UIApplication) {
let notificationSettings = UIUserNotificationSettings(
forTypes: [.Badge, .Sound, .Alert], categories: nil)
application.registerUserNotificationSettings(notificationSettings)
}
//註冊遠端推送通知了
func application(application: UIApplication,didRegisterUserNotificationSettings notificationSettings: UIUserNotificationSettings) {
if notificationSettings.types != .None {
application.registerForRemoteNotifications()
}
}
///deviceToken推送伺服器
func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) {
AVOSCloud.handleRemoteNotificationsWithDeviceToken(deviceToken)
}
//失敗
func application(application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: NSError) {
print(error)
}
複製程式碼
Swift 2 2 整合lean cloud Push推送
相關文章
- HTTP/2 伺服器推送(Server Push)教程HTTP伺服器Server
- Swift 整合友盟推送Swift
- HTTP/2之伺服器推送(Server Push)最佳實踐HTTP伺服器Server
- Swift3.0整合極光推送Swift
- HTTP/2 Server Push 詳解(下)HTTPServer
- HTTP2 Server Push的研究HTTPServer
- push推送詳解連結
- 關於推送uni-push
- 3個步驟輕鬆整合Push Kit,實現App訊息推送APP
- java9+springboot2+undertow2啟用http2及server pushJavaSpring BootHTTPServer
- iOS推送系列之Push的工作原理iOS
- 建立Git Push一鍵推送所有Git
- swift學習筆記《2》-swift語法Swift筆記
- React Native 整合code pushReact Native
- Swift 2 0 如何替代 pchSwift
- Android Push Notification實現資訊推送功能Android
- spring-cloud-oauth2SpringCloudOAuth
- PWA之推送伺服器(koa2+mysql+pm2)伺服器MySql
- Node HTTP/2 Server Push 從瞭解到放棄HTTPServer
- 基於 Laravel 中介軟體簡單地整合 HTTP/2 伺服器資源推送LaravelHTTP伺服器
- 如何配置Apple推送證書 push證書APP
- Springboot2+vue2整合專案Spring BootVue
- (2)Spring Cloud版本介紹SpringCloud
- SpringBoot整合系列-整合H2Spring Boot
- springboot2整合websocket,實現服務端推送訊息到客戶端Spring BootWeb服務端客戶端
- iOS整合Fabric & Crashlytics (2)iOS
- spring整合struts2Spring
- Strurs+Spring整合2Spring
- Spring Cloud :: Security :: OAuth2 – ⓪ OAuth2模型詳述SpringCloudOAuth模型
- 推薦一款 Flutter Push 推送功能外掛Flutter
- Spring Cloud 整合SpringCloud
- [MetalKit]11-Ray-tracing-in-a-Swift-playground2射線追蹤2Swift
- ios 時間 string 和 nsdate問題 swift2 2 ociOSSwift
- Swift2 2語法 語法 判斷手機型號Swift
- Spring Cloud Alibaba(2)---Nacos概述SpringCloud
- 2、Spring Cloud和dubbo簡介SpringCloud
- java B2B2C 原始碼多租戶電子商城系統-Spring Cloud整合Netflix Archaius介紹Java原始碼SpringCloudAI
- Struts2【與Spring整合】Spring