|
//
// AppDelegate.swift
// Paiai
//
// Created by FFIB on 16/3/28.
// Copyright © 2016年 FFIB. All rights reserved.
//
import UIKit
import RxSwift
import Paiai_iOS
import PaiaiDataKit
let WXAppid = "wx4e22a0c8ae6d766d"
let WXSecret = "636ac848016c593575d11143c55c8333"
private let QQAppid = "1105111674"
private let QQSecret = "OFQ2J1RBMJyHPW8G"
private let WBAppid = "2730190333"
private let WBSecret = "ff16591583c7bcf4a0d781eae316635a"
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, WXApiDelegate {
var window: UIWindow?
var coordinator: AppCoordinator?
let disposeBag = DisposeBag()
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?)
-> Bool {
registerAppConfiguration()
window = UIWindow(frame: UIScreen.main.bounds)
window?.backgroundColor = .white
coordinator = AppCoordinator(window: window!)
coordinator?.start().subscribe().disposed(by: disposeBag)
return true
}
func application(_ application: UIApplication, open url: URL,
sourceApplication: String?, annotation: Any) -> Bool {
// var result: Bool = false
#if !((arch(i386) || arch(x86_64)))
// switch sharedPlatform {
// case 0:
// result = WXApi.handleOpen(url, delegate: self)
// case 1:
// result = TencentOAuth.handleOpen(url)
// case 2:
// result = WeiboSDK.handleOpen(url, delegate: nil)
// default:
// assert(false, "\((#file as NSString).lastPathComponent)[\(#line)], \(#function): share error")
// }
#endif
return WXApi.handleOpen(url, delegate: self)
}
#if !((arch(i386) || arch(x86_64)))
func onResp(_ resp: BaseResp!) {
if let resp = resp as? PayResp {
let userInfo: [String: Int] = ["code": Int(resp.errCode)]
NotificationCenter.default.post(name: .wxPayDidFinish, object: nil, userInfo: userInfo)
} else if let resp = resp as? SendAuthResp {
let userInfo: [String: AnyObject] = ["errCode": Int(resp.errCode) as AnyObject,
"code": resp.code as AnyObject]
NotificationCenter.default.post(name: .wxLogin, object: nil, userInfo: userInfo)
}
}
#endif
func application(_ application: UIApplication, handleOpen url: URL) -> Bool {
return WXApi.handleOpen(url, delegate: self)
}
}
extension AppDelegate {
func registerAppConfiguration() {
WXApi.registerApp(WXAppid)
// _ = TencentOAuth(appId: QQAppid, andDelegate: nil)
// WeiboSDK.registerApp(WBAppid)
// let analyticsConfig = UMAnalyticsConfig.sharedInstance()
// analyticsConfig?.appKey = "58c5ebcdae1bf82bc9001ff9"
// analyticsConfig?.channelId = "App Store"
// MobClick.start(withConfigure: analyticsConfig)
UserDefaults.standard.register(defaults: [
"WIFIUploadOriginal": true,
"ReceivePush": true
])
}
}
|