Commit 2773fce27c2b64a4236a91cf3c52c707a96c255b

Authored by xiaoyu
1 parent d1dd2e71

集成ios友盟相关配置

ios/Runner.xcodeproj/project.pbxproj
... ... @@ -243,6 +243,8 @@
243 243 B891A8EA2BD257F4006CB06E /* RatePromptHandler_ios.mm in Sources */ = {isa = PBXBuildFile; fileRef = B891A8E82BD257F4006CB06E /* RatePromptHandler_ios.mm */; };
244 244 B891A8ED2BD25AFE006CB06E /* AniSoundUtils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B891A8EC2BD25AFE006CB06E /* AniSoundUtils.cpp */; };
245 245 B891A8EF2BD26895006CB06E /* StoreKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B891A8EE2BD26895006CB06E /* StoreKit.framework */; };
  246 + B89EC5202BEDF60B00ABE22D /* UMAnalyticsSwift.swift in Sources */ = {isa = PBXBuildFile; fileRef = B89EC51E2BEDF60A00ABE22D /* UMAnalyticsSwift.swift */; };
  247 + B89EC5212BEDF60B00ABE22D /* UMCommonSwift.swift in Sources */ = {isa = PBXBuildFile; fileRef = B89EC51F2BEDF60B00ABE22D /* UMCommonSwift.swift */; };
246 248 F5FCE34FB9E028C20A7850DE /* Pods_RunnerTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2A3DBEAB6142776646A34D9C /* Pods_RunnerTests.framework */; };
247 249 FB8AFCB0A8C34B5508A68F45 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6DEBBC1D861BE053F3ECE0B9 /* Pods_Runner.framework */; };
248 250 /* End PBXBuildFile section */
... ... @@ -930,6 +932,8 @@
930 932 B891A8EB2BD25AFE006CB06E /* AniSoundUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AniSoundUtils.h; sourceTree = "<group>"; };
931 933 B891A8EC2BD25AFE006CB06E /* AniSoundUtils.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AniSoundUtils.cpp; sourceTree = "<group>"; };
932 934 B891A8EE2BD26895006CB06E /* StoreKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = StoreKit.framework; path = System/Library/Frameworks/StoreKit.framework; sourceTree = SDKROOT; };
  935 + B89EC51E2BEDF60A00ABE22D /* UMAnalyticsSwift.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UMAnalyticsSwift.swift; sourceTree = "<group>"; };
  936 + B89EC51F2BEDF60B00ABE22D /* UMCommonSwift.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UMCommonSwift.swift; sourceTree = "<group>"; };
933 937 D63F3847140160A2204489BA /* Pods-RunnerTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.debug.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.debug.xcconfig"; sourceTree = "<group>"; };
934 938 D8C046A1A9C279FDBB5C174E /* Pods-RunnerTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.release.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.release.xcconfig"; sourceTree = "<group>"; };
935 939 F04D1DAE6591EAD461CBBE9A /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
... ... @@ -1013,6 +1017,7 @@
1013 1017 97C146F01CF9000F007C117D /* Runner */ = {
1014 1018 isa = PBXGroup;
1015 1019 children = (
  1020 + B89EC51C2BEDF5E500ABE22D /* UMeng */,
1016 1021 B891A25D2BCD102C006CB06E /* Wowgame */,
1017 1022 52450AF22A4ED0EC007B3E4B /* Runner.entitlements */,
1018 1023 97C146FA1CF9000F007C117D /* Main.storyboard */,
... ... @@ -1585,6 +1590,15 @@
1585 1590 path = NativeIOS;
1586 1591 sourceTree = "<group>";
1587 1592 };
  1593 + B89EC51C2BEDF5E500ABE22D /* UMeng */ = {
  1594 + isa = PBXGroup;
  1595 + children = (
  1596 + B89EC51E2BEDF60A00ABE22D /* UMAnalyticsSwift.swift */,
  1597 + B89EC51F2BEDF60B00ABE22D /* UMCommonSwift.swift */,
  1598 + );
  1599 + path = UMeng;
  1600 + sourceTree = "<group>";
  1601 + };
1588 1602 E653501EF99460B1BB76C5EE /* Frameworks */ = {
1589 1603 isa = PBXGroup;
1590 1604 children = (
... ... @@ -1986,6 +2000,7 @@
1986 2000 B891A8422BD24EFB006CB06E /* AniLayoutObject.cpp in Sources */,
1987 2001 B891A8DC2BD24EFB006CB06E /* HValueStorage.cpp in Sources */,
1988 2002 B891A8832BD24EFB006CB06E /* ToyContainerSprite.cpp in Sources */,
  2003 + B89EC5202BEDF60B00ABE22D /* UMAnalyticsSwift.swift in Sources */,
1989 2004 B891A8D62BD24EFB006CB06E /* HStringUtils.cpp in Sources */,
1990 2005 B891A8772BD24EFB006CB06E /* MapAdventureObjectPickupItem.cpp in Sources */,
1991 2006 B891A8A02BD24EFB006CB06E /* ToyResourcesConfig.cpp in Sources */,
... ... @@ -2152,6 +2167,7 @@
2152 2167 B891A8722BD24EFB006CB06E /* IMapImageObject.cpp in Sources */,
2153 2168 B891A8C82BD24EFB006CB06E /* HParentalGateShowInterface.cpp in Sources */,
2154 2169 B891A8202BD24EFB006CB06E /* StaticActionParser.cpp in Sources */,
  2170 + B89EC5212BEDF60B00ABE22D /* UMCommonSwift.swift in Sources */,
2155 2171 B891A8502BD24EFB006CB06E /* AniPickLevelScene.cpp in Sources */,
2156 2172 B891A8732BD24EFB006CB06E /* ISpriteAnimator.cpp in Sources */,
2157 2173 B891A8462BD24EFB006CB06E /* AniLevelView.cpp in Sources */,
... ...
ios/Runner/AppDelegate.swift
... ... @@ -7,6 +7,11 @@ import Flutter
7 7 _ application: UIApplication,
8 8 didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
9 9 ) -> Bool {
  10 +
  11 + // umeng初始化
  12 + UMCommonSwift.setLogEnabled(bFlag: true);
  13 + UMCommonSwift.initWithAppkey(appKey: "663b66b0b3362515012f4ea5", channel: "App Store");
  14 +
10 15 GeneratedPluginRegistrant.register(with: self)
11 16 let controller : FlutterViewController = window?.rootViewController as! FlutterViewController
12 17 _ = VoiceXSMessageChannel(messager: controller.binaryMessenger)
... ...
ios/Runner/Runner-Bridging-Header.h
1 1  
2   -#import "GeneratedPluginRegistrant.h"
  2 +
  3 +#ifndef Runner_Bridging_Header_h
  4 +#define Runner_Bridging_Header_h
  5 +
  6 +// SingSound
3 7 #import <SingSound/SSOralEvaluatingManager.h>
4 8  
  9 +// UMCommon
  10 +#import <UMCommon/UMCommon.h>
  11 +#import <UMCommon/UMConfigure.h>
  12 +#import <UMCommon/MobClick.h>
  13 +
  14 +// UMAPM
  15 +#import <UMAPM/UMLaunch.h>
  16 +#import <UMAPM/UMAPMConfig.h>
  17 +#import <UMAPM/UMCrashConfigure.h>
  18 +
  19 +
  20 +#import "GeneratedPluginRegistrant.h"
5 21 #import "WowGameCocosManager.h"
6 22  
  23 +#endif /* Runner_Bridging_Header_h */
... ...
ios/Runner/UMeng/UMAnalyticsSwift.swift 0 → 100644
  1 +//
  2 +// UMAnalyticsSwift.swift
  3 +// swiftDemo
  4 +//
  5 +// Created by wangkai on 2019/8/30.
  6 +// Copyright © 2019 wangkai. All rights reserved.
  7 +//
  8 +
  9 +import Foundation
  10 +import CoreLocation
  11 +
  12 +class UMAnalyticsSwift: NSObject {
  13 +
  14 +
  15 + //页面统计
  16 + /** 手动页面时长统计, 记录某个页面展示的时长.
  17 + @param pageName 统计的页面名称.
  18 + @param seconds 单位为秒,int型.
  19 + @return void.
  20 + */
  21 + static func logPageView(pageName:String,seconds:Int){
  22 + MobClick.logPageView(pageName, seconds:Int32(seconds));
  23 + }
  24 +
  25 + /** 自动页面时长统计, 开始记录某个页面展示时长.
  26 + 使用方法:必须配对调用beginLogPageView:和endLogPageView:两个函数来完成自动统计,若只调用某一个函数不会生成有效数据。
  27 + 在该页面展示时调用beginLogPageView:,当退出该页面时调用endLogPageView:
  28 + @param pageName 统计的页面名称.
  29 + @return void.
  30 + */
  31 + static func beginLogPageView(pageName:String){
  32 + MobClick.beginLogPageView(pageName);
  33 + }
  34 +
  35 + /** 自动页面时长统计, 结束记录某个页面展示时长.
  36 + 使用方法:必须配对调用beginLogPageView:和endLogPageView:两个函数来完成自动统计,若只调用某一个函数不会生成有效数据。
  37 + 在该页面展示时调用beginLogPageView:,当退出该页面时调用endLogPageView:
  38 + @param pageName 统计的页面名称.
  39 + @return void.
  40 + */
  41 + static func endLogPageView(pageName:String){
  42 + MobClick.endLogPageView(pageName);
  43 + }
  44 +
  45 + //事件统计
  46 + /** 自定义事件,数量统计.
  47 + 使用前,请先到友盟App管理后台的设置->编辑自定义事件 中添加相应的事件ID,然后在工程中传入相应的事件ID
  48 +
  49 + @param eventId 网站上注册的事件Id.
  50 + @param label 分类标签。不同的标签会分别进行统计,方便同一事件的不同标签的对比,为nil或空字符串时后台会生成和eventId同名的标签.
  51 + @param accumulation 累加值。为减少网络交互,可以自行对某一事件ID的某一分类标签进行累加,再传入次数作为参数。
  52 + @return void.
  53 + */
  54 + static func event(eventId:String){
  55 + MobClick.event(eventId);
  56 + }
  57 + /** 自定义事件,数量统计.
  58 + 使用前,请先到友盟App管理后台的设置->编辑自定义事件 中添加相应的事件ID,然后在工程中传入相应的事件ID
  59 + */
  60 + // label为nil或@""时,等同于 event:eventId label:eventId;
  61 + static func event(eventId:String,label:String){
  62 + MobClick.event(eventId, label: label);
  63 + }
  64 +
  65 + /** 自定义事件,数量统计.
  66 + 使用前,请先到友盟App管理后台的设置->编辑自定义事件 中添加相应的事件ID,然后在工程中传入相应的事件ID
  67 + */
  68 + static func event(eventId:String,attributes:Dictionary<String, Any>){
  69 + MobClick.event(eventId, attributes:attributes);
  70 + }
  71 +
  72 + static func event(eventId:String,attributes:Dictionary<String, Any>,counter:Int){
  73 + MobClick.event(eventId, attributes: attributes, counter: Int32(counter));
  74 + }
  75 +
  76 + /** 自定义事件,时长统计.
  77 + 使用前,请先到友盟App管理后台的设置->编辑自定义事件 中添加相应的事件ID,然后在工程中传入相应的事件ID.
  78 + beginEvent,endEvent要配对使用,也可以自己计时后通过durations参数传递进来
  79 +
  80 + @param eventId 网站上注册的事件Id.
  81 + @param label 分类标签。不同的标签会分别进行统计,方便同一事件的不同标签的对比,为nil或空字符串时后台会生成和eventId同名的标签.
  82 + @param primarykey 这个参数用于和event_id一起标示一个唯一事件,并不会被统计;对于同一个事件在beginEvent和endEvent 中要传递相同的eventId 和 primarykey
  83 + @param millisecond 自己计时需要的话需要传毫秒进来
  84 + @return void.
  85 +
  86 + @warning 每个event的attributes不能超过10个
  87 + eventId、attributes中key和value都不能使用空格和特殊字符,必须是NSString,且长度不能超过255个字符(否则将截取前255个字符)
  88 + id, ts, du是保留字段,不能作为eventId及key的名称
  89 + */
  90 + static func beginEvent(eventId:String){
  91 + MobClick.beginEvent(eventId);
  92 + }
  93 +
  94 + /** 自定义事件,时长统计.
  95 + 使用前,请先到友盟App管理后台的设置->编辑自定义事件 中添加相应的事件ID,然后在工程中传入相应的事件ID.
  96 + */
  97 + static func endEvent(eventId:String){
  98 + MobClick.endEvent(eventId);
  99 + }
  100 +
  101 + /** 自定义事件,时长统计.
  102 + 使用前,请先到友盟App管理后台的设置->编辑自定义事件 中添加相应的事件ID,然后在工程中传入相应的事件ID.
  103 + */
  104 + static func beginEvent(eventId:String,label:String){
  105 + MobClick.beginEvent(eventId, label: label);
  106 + }
  107 +
  108 + /** 自定义事件,时长统计.
  109 + 使用前,请先到友盟App管理后台的设置->编辑自定义事件 中添加相应的事件ID,然后在工程中传入相应的事件ID.
  110 + */
  111 + static func endEvent(eventId:String,label:String){
  112 + MobClick.endEvent(eventId, label: label);
  113 + }
  114 +
  115 + /** 自定义事件,时长统计.
  116 + 使用前,请先到友盟App管理后台的设置->编辑自定义事件 中添加相应的事件ID,然后在工程中传入相应的事件ID.
  117 + */
  118 + static func beginEvent(eventId:String,primarykey:String,attributes:Dictionary<String, Any>){
  119 + MobClick.beginEvent(eventId, primarykey: primarykey, attributes: attributes);
  120 + }
  121 +
  122 + /** 自定义事件,时长统计.
  123 + 使用前,请先到友盟App管理后台的设置->编辑自定义事件 中添加相应的事件ID,然后在工程中传入相应的事件ID.
  124 + */
  125 + static func endEvent(eventId:String,primarykey:String){
  126 + MobClick.endEvent(eventId, primarykey: primarykey);
  127 + }
  128 +
  129 + /** 自定义事件,时长统计.
  130 + 使用前,请先到友盟App管理后台的设置->编辑自定义事件 中添加相应的事件ID,然后在工程中传入相应的事件ID.
  131 + */
  132 + static func event(eventId:String,durations:Int){
  133 + MobClick.event(eventId, durations: Int32(durations))
  134 + }
  135 +
  136 + /** 自定义事件,时长统计.
  137 + 使用前,请先到友盟App管理后台的设置->编辑自定义事件 中添加相应的事件ID,然后在工程中传入相应的事件ID.
  138 + */
  139 + static func event(eventId:String,label:String,millisecond:Int){
  140 + MobClick.event(eventId, label: label, durations: Int32(millisecond));
  141 + }
  142 +
  143 + /** 自定义事件,时长统计.
  144 + 使用前,请先到友盟App管理后台的设置->编辑自定义事件 中添加相应的事件ID,然后在工程中传入相应的事件ID.
  145 + */
  146 + static func event(eventId:String,attributes:Dictionary<String, Any>,millisecond:Int){
  147 + MobClick.event(eventId, attributes: attributes, durations: Int32(millisecond));
  148 + }
  149 +
  150 +
  151 + /** active user sign-in.
  152 + 使用sign-In函数后,如果结束该PUID的统计,需要调用sign-Off函数
  153 + @param puid : user's ID
  154 + @param provider : 不能以下划线"_"开头,使用大写字母和数字标识; 如果是上市公司,建议使用股票代码。
  155 + @return void.
  156 + */
  157 + static func profileSignInWithPUID(puid:String){
  158 + MobClick.profileSignIn(withPUID: puid);
  159 + }
  160 + static func profileSignInWithPUID(puid:String,provider:String){
  161 + MobClick.profileSignIn(withPUID:puid, provider: provider);
  162 + }
  163 +
  164 + /** active user sign-off.
  165 + 停止sign-in PUID的统计
  166 + @return void.
  167 + */
  168 + static func profileSignOff(){
  169 + MobClick.profileSignOff();
  170 + }
  171 +
  172 + ///---------------------------------------------------------------------------------------
  173 + /// @name 地理位置设置
  174 + /// 需要链接 CoreLocation.framework 并且 #import <CoreLocation/CoreLocation.h>
  175 + ///---------------------------------------------------------------------------------------
  176 +
  177 + /** 设置经纬度信息
  178 + @param latitude 纬度.
  179 + @param longitude 经度.
  180 + @return void
  181 + */
  182 + static func setLatitude(latitude:Double,longitude:Double){
  183 + MobClick.setLatitude(latitude, longitude: longitude);
  184 + }
  185 +
  186 +
  187 + ///---------------------------------------------------------------------------------------
  188 + /// @name Utility函数
  189 + ///---------------------------------------------------------------------------------------
  190 +
  191 + /** 判断设备是否越狱,依据是否存在apt和Cydia.app
  192 + */
  193 + static func isJailbroken() -> Bool{
  194 + return MobClick.isJailbroken();
  195 + }
  196 +
  197 + /** 判断App是否被破解
  198 + */
  199 + static func isPirated() -> Bool{
  200 + return MobClick.isPirated();
  201 + }
  202 +
  203 +
  204 +
  205 + /**
  206 + * 设置预置事件属性 键值对 会覆盖同名的key
  207 + */
  208 + static func registerPreProperties(property:Dictionary<String, Any>)
  209 + {
  210 + MobClick.registerPreProperties(property);
  211 + }
  212 +
  213 + /**
  214 + *
  215 + * 删除指定预置事件属性
  216 + @param key
  217 + */
  218 + static func unregisterPreProperty(propertyName:String)
  219 + {
  220 + MobClick.unregisterPreProperty(propertyName);
  221 + }
  222 +
  223 + /**
  224 + * 获取预置事件所有属性;如果不存在,则返回空。
  225 + */
  226 + static func getPreProperties() -> Dictionary<String, Any>
  227 + {
  228 + return MobClick.getPreProperties() as! Dictionary<String, Any> ;
  229 + }
  230 +
  231 + /**
  232 + *清空所有预置事件属性。
  233 + */
  234 + static func clearPreProperties()
  235 + {
  236 + MobClick.clearPreProperties();
  237 + }
  238 +
  239 +
  240 + /**
  241 + * 设置关注事件是否首次触发,只关注eventList前五个合法eventID.只要已经保存五个,此接口无效
  242 + */
  243 + static func setFirstLaunchEvent(eventList:Array<String>)
  244 + {
  245 + MobClick.setFirstLaunchEvent(eventList);
  246 + }
  247 +
  248 + /** 设置是否自动采集页面, 默认NO(不自动采集).
  249 + @param value 设置为YES, umeng SDK 会将自动采集页面信息
  250 + */
  251 + static func setAutoPageEnabled(value:Bool)
  252 + {
  253 + MobClick.setAutoPageEnabled(value);
  254 + }
  255 +
  256 +}
... ...
ios/Runner/UMeng/UMCommonSwift.swift 0 → 100644
  1 +//
  2 +// UMCommonSwift.swift
  3 +// swiftDemo
  4 +//
  5 +// Created by wangkai on 2019/8/29.
  6 +// Copyright © 2019 wangkai. All rights reserved.
  7 +//
  8 +
  9 +import Foundation
  10 +import OpenGLES
  11 +
  12 +
  13 +class UMCommonSwift: NSObject {
  14 +
  15 + /** 初始化友盟所有组件产品
  16 + @param appKey 开发者在友盟官网申请的appkey.
  17 + @param channel 渠道标识,可设置nil表示"App Store".
  18 + */
  19 + static func initWithAppkey(appKey:String,channel:String){
  20 + let config = UMAPMConfig.default();
  21 +
  22 + config.crashAndBlockMonitorEnable = true;
  23 + config.launchMonitorEnable = true;
  24 + config.memMonitorEnable = true;
  25 + config.oomMonitorEnable = true;
  26 + config.networkEnable = true;
  27 + config.javaScriptBridgeEnable = true;
  28 + config.pageMonitorEnable = true;
  29 +
  30 + UMCrashConfigure.setAPMConfig(config);
  31 + UMConfigure.initWithAppkey(appKey, channel: channel);
  32 + UMConfigure.setLogEnabled(true);
  33 +
  34 + }
  35 +
  36 + /** 设置是否在console输出sdk的log信息.
  37 + @param bFlag 默认NO(不输出log); 设置为YES, 输出可供调试参考的log信息. 发布产品时必须设置为NO.
  38 + */
  39 + static func setLogEnabled(bFlag:Bool){
  40 + UMConfigure.setLogEnabled(bFlag);
  41 + }
  42 +
  43 + /** 设置是否对日志信息进行加密, 默认NO(不加密).
  44 + @param value 设置为YES, umeng SDK 会将日志信息做加密处理
  45 + */
  46 + static func setEncryptEnabled(value:Bool){
  47 + UMConfigure.setEncryptEnabled(value);
  48 + }
  49 +
  50 + static func umidString() -> String{
  51 + return UMConfigure.umidString();
  52 + }
  53 +
  54 + /**
  55 + 集成测试需要device_id
  56 + */
  57 + static func deviceIDForIntegration() -> String{
  58 + return UMConfigure.deviceIDForIntegration();
  59 + }
  60 +}
... ...