|
//
// AppDelegate.swift
// PaiAi
//
// Created by zhengjianfei on 16/3/28.
// Copyright © 2016年 FFIB. All rights reserved.
//
import UIKit
import Paiai_iOS
import PaiaiUIKit
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?
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?)
-> Bool {
registerAppConfiguration()
let rootViewController = ContainerViewController()
let nav = UINavigationController(rootViewController: rootViewController)
rootViewController.setupNavigationBarPushAndPopDelegate()
window = UIWindow(frame: UIScreen.main.bounds)
window?.rootViewController = nav
window?.makeKeyAndVisible()
coordinator = AppCoordinator(rootViewController, navigationController: nav)
nav.navigationBar.tintColor = UIColor.white
nav.navigationBar.isTranslucent = false
nav.navigationBar.setBackgroundImage(UIImage.Navigation.background, for: .default)
nav.navigationBar.titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.white.cgColor]
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: Notification.wxNotification.payDidFinish, 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: Notification.wxNotification.login, object: nil, userInfo: userInfo)
}
}
#endif
func application(_ application: UIApplication, handleOpen url: URL) -> Bool {
return WXApi.handleOpen(url, delegate: self)
}
}
private let WIFIUploadOriginal = "WIFIUploadOriginal"
private let ReceivePush = "ReceivePush"
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
])
}
}
|