1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- //
- // AppDelegate+HandleOpen.swift
- // RainbowPlanet
- //
- // Created by 南鑫林 on 2019/3/8.
- // Copyright © 2019 南鑫林. All rights reserved.
- //
- import Foundation
- //MARK: - 设置系统回调
- extension AppDelegate {
- //仅支持iOS9以上系统,iOS8及以下系统不会回调
- func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
- //6.3的新的API调用,是为了兼容国外平台(例如:新版facebookSDK,VK等)的调用[如果用6.2的api调用会没有回调],对国内平台没有影响
- var result = UMSocialManager.default().handleOpen(url, options: options)
- if (!result) {
- // 其他如支付等SDK的回调
- result = PayManager.shared().handleOpen(url: url)
- if !result {
- // 自己路由
- result = RouterManager.shared.handleOpen(url: url)
- return result
- }
- return result
- }
- return result;
- }
- //支持目前所有iOS系统
- func application(_ application: UIApplication, handleOpen url: URL) -> Bool {
- var result = UMSocialManager.default().handleOpen(url)
- if (!result) {
- // 其他如支付等SDK的回调
- result = PayManager.shared().handleOpen(url: url)
- if !result {
- // 自己路由
- result = RouterManager.shared.handleOpen(url: url)
- return result
- }
- return result
- }
- return result;
- }
- //iOS10以下使用这两个方法接收通知,
- func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
- //关闭友盟自带的弹出框
- UMessage.setAutoAlert(false)
- UMessage.didReceiveRemoteNotification(userInfo)
- RouterManager.shared.UMPush(pushModel: PushModel(JSONString: userInfo.description) ?? PushModel())
- completionHandler(UIBackgroundFetchResult.newData);
- }
- func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any]) {
- //关闭友盟自带的弹出框
- UMessage.setAutoAlert(false)
- RouterManager.shared.UMPush(pushModel: PushModel(JSONString: userInfo.description) ?? PushModel())
- // 接受笑死通知
- UMessage.didReceiveRemoteNotification(userInfo)
- }
- /// 获取设备的 DeviceToken
- func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
- UMessage.registerDeviceToken(deviceToken)
- }
- }
|