123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167 |
- //
- // CommonUMengShare.swift
- // CommonFrame
- //
- // Created by Virgil on 2017/1/10.
- // Copyright © 2017年 Virgil. All rights reserved.
- //
- import UIKit
- class CommonUMengShare: NSObject {
- class func showSharedMenuCus(viewController: UIViewController, title: String, desc: String, icon: UIImage, url: String, img: UIImage) {
- UMSocialUIManager.addCustomPlatformWithoutFilted(UMSocialPlatformType(rawValue: 1002)!, withPlatformIcon: UIImage(named: "code_news"), withPlatformName: "二维码海报")
- CommonOC.setUMCus()
- UMSocialUIManager.showShareMenuViewInWindow { (type, _) in
- if type.rawValue == 1002 {
- let messageObject = UMSocialMessageObject()
- //内容体 (分享图文:UMShareImageObject 音乐:UMShareMusicObject 视频:UMShareVideoObject
- let messagess = UMShareImageObject()
- messagess.shareImage = img
- messageObject.shareObject = messagess
- UMSocialManager.default().share(to: .wechatTimeLine, messageObject: messageObject, currentViewController: viewController, completion: { (_, _) in
- })
- } else {
- let messageObject = UMSocialMessageObject()
- //内容体 (分享图文:UMShareImageObject 音乐:UMShareMusicObject 视频:UMShareVideoObject
- let messagess = UMShareWebpageObject()
- messagess.descr = desc
- messagess.title = title
- messagess.webpageUrl = url
- messagess.thumbImage = icon
- messageObject.shareObject = messagess
- UMSocialManager.default().share(to: type, messageObject: messageObject, currentViewController: viewController, completion: { (_, error) in
- print("=======error==\(String(describing: error))=")
- })
- }
- }
- }
- class func showSharedMenu(viewController: UIViewController, title: String, desc: String, icon: UIImage, url: String) {
- UMSocialUIManager.removeCustomPlatformWithoutFilted(UMSocialPlatformType(rawValue: 1002)!)
- CommonOC.setUM()
- // UMSocialUIManager.setPreDefinePlatforms([UMSocialPlatformType.wechatSession,UMSocialPlatformType.wechatTimeLine])
- UMSocialUIManager.addCustomPlatformWithoutFilted(.userDefine_Begin, withPlatformIcon: UIImage(named: "code_news"), withPlatformName: "二维码海报")
- UMSocialUIManager.showShareMenuViewInWindow { (type, _) in
- let messageObject = UMSocialMessageObject()
- //内容体 (分享图文:UMShareImageObject 音乐:UMShareMusicObject 视频:UMShareVideoObject
- let messagess = UMShareWebpageObject()
- messagess.descr = desc
- messagess.title = title
- messagess.webpageUrl = url
- messagess.thumbImage = icon
- messageObject.shareObject = messagess
- UMSocialManager.default().share(to: type, messageObject: messageObject, currentViewController: viewController, completion: { (_, error) in
- print("=======error==\(String(describing: error))=")
- })
- }
- }
- class func showSharedMenu(viewController: UIViewController, title: String, desc: String, icon: UIImage, url: String, reBack:@escaping RebackFunction) {
- UMSocialUIManager.removeCustomPlatformWithoutFilted(UMSocialPlatformType(rawValue: 1002)!)
- CommonOC.setUM()
- // UMSocialUIManager.setPreDefinePlatforms([UMSocialPlatformType.wechatSession,UMSocialPlatformType.wechatTimeLine])
- UMSocialUIManager.showShareMenuViewInWindow { (type, _) in
- let messageObject = UMSocialMessageObject()
- //内容体 (分享图文:UMShareImageObject 音乐:UMShareMusicObject 视频:UMShareVideoObject
- let messagess = UMShareWebpageObject()
- messagess.descr = desc
- messagess.title = title
- messagess.webpageUrl = url
- messagess.thumbImage = icon
- messageObject.shareObject = messagess
- UMSocialManager.default().share(to: type, messageObject: messageObject, currentViewController: viewController, completion: { (_, error) in
- if error == nil {
- reBack(1, "")
- } else {
- reBack(0, "")
- }
- })
- }
- }
- class func showSharedMenuWX(viewController: UIViewController, title: String, desc: String, icon: UIImage, url: String, reBack:@escaping RebackFunction) {
- UMSocialUIManager.removeCustomPlatformWithoutFilted(UMSocialPlatformType(rawValue: 1002)!)
- CommonOC.setUMWX()
- // UMSocialUIManager.setPreDefinePlatforms([UMSocialPlatformType.wechatSession,UMSocialPlatformType.wechatTimeLine])
- UMSocialUIManager.showShareMenuViewInWindow { (type, _) in
- let messageObject = UMSocialMessageObject()
- //内容体 (分享图文:UMShareImageObject 音乐:UMShareMusicObject 视频:UMShareVideoObject
- let messagess = UMShareWebpageObject()
- messagess.descr = desc
- messagess.title = title
- messagess.webpageUrl = url
- messagess.thumbImage = icon
- messageObject.shareObject = messagess
- UMSocialManager.default().share(to: type, messageObject: messageObject, currentViewController: viewController, completion: { (_, error) in
- if error == nil {
- reBack(1, "")
- } else {
- reBack(0, "")
- }
- })
- }
- }
- class func showSharedMenu(viewController: UIViewController, img: UIImage, reBack:@escaping RebackFunction) {
- UMSocialUIManager.removeCustomPlatformWithoutFilted(UMSocialPlatformType(rawValue: 1002)!)
- CommonOC.setUM()
- // UMSocialUIManager.setPreDefinePlatforms([UMSocialPlatformType.wechatSession,UMSocialPlatformType.wechatTimeLine])
- UMSocialUIManager.showShareMenuViewInWindow { (type, _) in
- let messageObject = UMSocialMessageObject()
- //内容体 (分享图文:UMShareImageObject 音乐:UMShareMusicObject 视频:UMShareVideoObject
- let messagess = UMShareImageObject()
- messagess.shareImage = img
- messageObject.shareObject = messagess
- UMSocialManager.default().share(to: type, messageObject: messageObject, currentViewController: viewController, completion: { (_, error) in
- if error == nil {
- reBack(1, "")
- } else {
- reBack(0, "")
- }
- })
- }
- }
- //第三方登陆
- class func thirdLogin(viewController: UIViewController, platformType: UMSocialPlatformType) {
- UMSocialManager.default().getUserInfo(with: platformType, currentViewController: viewController) { (result, _) in
- let resp = result as! UMSocialUserInfoResponse
- print(" uid: \(resp.uid ?? "")")
- print(" openid: \(resp.openid ?? "")")
- print(" accessToken: \(resp.accessToken ?? "")")
- print(" refreshToken: \(resp.refreshToken ?? "")")
- print(" expiration: \(String(describing: resp.expiration))")
- // 用户数据
- print(" name: \(resp.name ?? "")")
- print(" iconurl: \(resp.iconurl ?? "")")
- print(" gender: \(resp.gender ?? "")")
- // 第三方平台SDK原始数据
- print(" originalResponse: \(String(describing: resp.originalResponse))")
- }
- }
- }
|