极光推送android点击跳转页面,app关闭时点击推送消息实现页面跳转

这段代码展示了在iOS应用中如何处理启动时的远程通知。首先,根据系统版本注册远程通知类型,包括Badge、Sound和Alert。接着,设置APService并检查是否由通知启动应用。如果应用是通过通知启动的,则不处理推送消息;否则,处理并更新数据。同时,定义了接收到远程通知时的处理方法,包括处理通知信息并完成后台数据获取。
摘要由CSDN通过智能技术生成

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

//推送注册

var str:NSString = UIDevice.currentDevice().systemVersion

var version:Float = str.floatValue

if version >= 8.0 {

APService.registerForRemoteNotificationTypes(UIUserNotificationType.Badge.rawValue | UIUserNotificationType.Sound.rawValue | UIUserNotificationType.Alert.rawValue, categories: nil)

} else {

APService.registerForRemoteNotificationTypes(UIRemoteNotificationType.Badge.rawValue | UIRemoteNotificationType.Sound.rawValue | UIRemoteNotificationType.Alert.rawValue, categories: nil)

}

APService.setupWithOption(launchOptions)

if launchOptions != nil {

isLauncheByNotification = true

}

return true

}

func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject], fetchCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void) {

var user = userInfo as NSDictionary

var aps = user.valueForKey("aps") as! NSDictionary

var str = aps.valueForKey("alert") as! String

if isLauncheByNotification == true {

//post消息没有启动

NSNotificationCenter.defaultCenter().postNotificationName("push", object: nil, userInfo: userInfo)

}

APService.handleRemoteNotification(userInfo)

completionHandler(UIBackgroundFetchResult.NewData)

}

求大神给个提示

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值