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
- HTTP/2之伺服器推送(Server Push)最佳實踐HTTP伺服器Server
- 關於推送uni-push
- 3個步驟輕鬆整合Push Kit,實現App訊息推送APP
- java9+springboot2+undertow2啟用http2及server pushJavaSpring BootHTTPServer
- swift學習筆記《2》-swift語法Swift筆記
- React Native 整合code pushReact Native
- iOS推送系列之Push的工作原理iOS
- 建立Git Push一鍵推送所有Git
- spring-cloud-oauth2SpringCloudOAuth
- Springboot2+vue2整合專案Spring BootVue
- PWA之推送伺服器(koa2+mysql+pm2)伺服器MySql
- SpringBoot整合系列-整合H2Spring Boot
- springboot2整合websocket,實現服務端推送訊息到客戶端Spring BootWeb服務端客戶端
- 如何配置Apple推送證書 push證書APP
- (2)Spring Cloud版本介紹SpringCloud
- Spring Cloud Alibaba(2)---Nacos概述SpringCloud
- Node HTTP/2 Server Push 從瞭解到放棄HTTPServer
- springboot整合swagger2Spring BootSwagger
- java B2B2C 原始碼多租戶電子商城系統-Spring Cloud整合Netflix Archaius介紹Java原始碼SpringCloudAI
- Spring Cloud :: Security :: OAuth2 – ⓪ OAuth2模型詳述SpringCloudOAuth模型
- 2、Spring Cloud和dubbo簡介SpringCloud
- [swift 進階]讀書筆記-C2P2字典Swift筆記
- SpringBoot 2.X 整合 RocketMQ遇到的問題2Spring BootMQ
- Struts2【與Spring整合】Spring
- 推薦一款 Flutter Push 推送功能外掛Flutter
- Spring Cloud 整合SpringCloud
- (九) SpringBoot起飛之路-整合/整合Swagger 2 And 3Spring BootSwagger
- Spring Boot2 系列教程(十七)SpringBoot 整合 Swagger2Spring BootSwagger
- EMQX Newsletter 2022-07|EMQX 5.0 正式釋出、EMQX Cloud 新增 2 個資料庫整合MQCloud資料庫
- java版電子商務spring cloud分散式微服務b2b2c-Spring Cloud TaskJavaSpringCloud分散式微服務
- SpringBoot整合Swagger2及使用Spring BootSwagger
- Swift工程如何整合Static LibrarySwift
- 2.springboot2.x整合mysql和mybatis(以xml的方式)Spring BootMySqlMyBatisXML
- spring cloud 整合 nacosSpringCloud
- (十一) 整合spring cloud雲架構 - SSO單點登入之OAuth2.0登入流程(2)SpringCloud架構OAuth
- Spring cloud(2)-服務發現(Eureka,Consul)SpringCloud
- Git 同時 push 推送到 GitHub、gitee 等多個平臺GithubGitee
- [譯] Node.js 能進行 HTTP/2 推送啦!Node.jsHTTP