12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- //
- // AppDelegate+HandleOpen.swift
- // RainbowPlanet
- //
- // Created by 南鑫林 on 2019/3/8.
- // Copyright © 2019 南鑫林. All rights reserved.
- //
- import Foundation
- //MARK: - 设置系统回调
- extension AppDelegate {
- //注:此方法在swift4.1(Xcode 9.3)已废弃,Objective-C项目不影响。 新浪 平台外的其他平台可在swift项目中使用下面两种回调方法。
- func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
- //6.3的新的API调用,是为了兼容国外平台(例如:新版facebookSDK,VK等)的调用[如果用6.2的api调用会没有回调],对国内平台没有影响
- var result = UMSocialManager.default().handleOpen(url, sourceApplication: sourceApplication, annotation: annotation)
- if (!result) {
- // 其他如支付等SDK的回调
- result = PayManager.shared().handleOpen(url: url)
- return result
- }
- return result;
- }
- //仅支持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)
- 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)
- return result
- }
- return result;
- }
- //iOS10以下使用这两个方法接收通知,
- func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
- //关闭友盟自带的弹出框
- UMessage.setAutoAlert(true)
- if #available(iOS 9.0, *) {
- if #available(iOS 10.0, *){
- }else {
- UMessage.didReceiveRemoteNotification(userInfo)
- completionHandler(UIBackgroundFetchResult.newData);
- }
- }
- }
- func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any]) {
- //关闭友盟自带的弹出框
- UMessage.setAutoAlert(true)
- if #available(iOS 9.0, *) {
- if #available(iOS 10.0, *){
- }else {
- UMessage.didReceiveRemoteNotification(userInfo)
- }
- }
- }
- /// 获取设备的 DeviceToken
- func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
- NXLLog(deviceToken.description.replacingOccurrences(of: "<", with: "").replacingOccurrences(of: ">", with: "").replacingOccurrences(of: " ", with: ""))
- }
- }
|