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推送
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- 友盟 push SDK 提供了基于 Objective-c 的集成方案,但是没有提供详细的和 swift 的集成方...
- 不得不说极光推送有一点做得是很不到位,swift都发布那么久了,官方提供的API尽然没有提供任何关于swift的A...