中小企业网站建设流程,怎么用网站做淘宝客,中铁建门户网登录入口,wordpress最近更新模块本文档以unity2020.3.41演示
集成准备
注册账号
使用MobSDK之前#xff0c;需要先在MobTech官网注册开发者账号#xff0c;并获取MobTech提供的AppKey和AppSecret#xff0c;详情可以点击查看注册流程
下载.unitypackage包
打开 Github 下载 MobPush-For-Unity 项目需要先在MobTech官网注册开发者账号并获取MobTech提供的AppKey和AppSecret详情可以点击查看注册流程
下载.unitypackage包
打开 Github 下载 MobPush-For-Unity 项目下载完成后直接双击或者在Unity里面选择打开 MobPush.unitypackage导入相关资源和脚本到您的 Unity项目即可使用。
导入unitypackage
全部选择即可其中Demo.cs 为API使用和页面示例可删除修改unity 编译环境 Android 集成编译配置
资源修改
删掉Android目录下的 baseProjectTemplate.gradle 、launcherTemplate.gradle文件
修改unity配置
使用系统的gradle配置文件
增加MobPush的gradle配置
修改baseProjectTemplate.gradle和launcherTemplate.gradle注此处修改为新生成的baseProjectTemplate.gradle文件和launcherTemplate.gradle文件 baseProjectTemplate.gradle 1.在classpath com.android.tools.build:gradle’后添加mob的classpath
classpath com.mob.sdk:MobSDK:2.添加MobPush需要的maven地址
maven { url https://mvn.mob.com/android/}3.参考示例如截图 launcherTemplate.gradle 1.修改launcherTemplate.gradle增加MobPush配置
apply plugin: com.mob.sdk
MobSDK {appKey xxxxxxxxxappSecret xxxxxxxxxxMobPush {debugLevel 4devInfo {HUAWEI{appId xxxxxxxxx}XIAOMI {appId xxxxxxxappKey 5581830029242}MEIZU {appId xxxxxappKey 3fc6d1acc7ea4f90a0304967ee3a74ae}OPPO {appKey xxxxxxxxappSecret c850609d8a0f492f8b9eeca1189aaec2}VIVO {appId xxxxxxappKey 9b01729c-6140-4ad3-ac79-4c4543e12130}}}
}2.参考示例截图 ##在gradle.properties中添加代码
MobSDK.spEditionFP挂载MobPush如图 配置签名文件和包名
1.配置自己项目的签名文件 2.配置自己项目的包名
设置隐私授权回调
为保证您的App在集成MobSDK之后能够满足工信部相关合规要求您应确保App安装首次冷启动且取得用户阅读您《隐私政策》授权之后调用Mob提交到的隐私协议回传函数uploadPrivacyPermissionStatus回传隐私协议授权结果。 反之如果用户不同意您App《隐私政策》授权则不能调用uploadPrivacyPermissionStatus回传隐私协议授权结果。 详情参考合规指南
//隐私授权接口调用此接口务必不能漏调用否则导致SDK不生效
mobPush.updatePrivacyPermissionStatus(true);推送接口
初始化和绑定监听(gameObject.GetComponent)
void Start (){mobPush gameObject.GetComponent();//初始化MobPushmobPush.onNotifyCallback OnNitifyHandler;//消息回调监听mobPush.onTagsCallback OnTagsHandler;//标签处理回调监听mobPush.onAliasCallback OnAliasHandler;//别名处理回调监听mobPush.onDemoReqCallback OnDemoReqHandler;//demo请求接口回调(为了方便测试提供在客户端发送通知的接口仅供测试时使用)mobPush.onRegIdCallback OnRegIdHandler;//获取注册ID异步监听回调接口}void OnNitifyHandler (int action, Hashtable resulte){Debug.Log (OnNitifyHandler);if (action ResponseState.CoutomMessage){Debug.Log (CoutomMessage: MiniJSON.jsonEncode(resulte));}else if (action ResponseState.MessageRecvice){Debug.Log (MessageRecvice: MiniJSON.jsonEncode(resulte));}else if (action ResponseState.MessageOpened) {Debug.Log (MessageOpened: MiniJSON.jsonEncode(resulte));}}
void OnTagsHandler (int action, string[] tags, int operation, int errorCode){Debug.Log (OnTagsHandler action: action tags: String.Join (,, tags) operation: operation errorCode: errorCode);}
void OnAliasHandler (int action, string alias, int operation, int errorCode){Debug.Log (OnAliasHandler action: action alias: alias operation: operation errorCode: errorCode);}
void OnRegIdHandler (string regId){Debug.Log (OnRegIdHandler-regId: regId);}
void OnDemoReqHandler (bool isSuccess){Debug.Log (OnDemoReqHandler: isSuccess);}发送本地通知(LocalNotifyStyle )
LocalNotifyStyle style new LocalNotifyStyle ();
style.setContent (Text);
style.setTitle (title);#if UNITY_ANDROID
Hashtable extras new Hashtable ();
extras[key1] value1;
extras[key2] value1;
style.setExtras (extras);
//指定时间当前时间加上设置这个Timestamp的值之后下发单位ms
style.setTimestamp(180000);
#endif
mobPush.setMobPushLocalNotification (style);自定义通知栏样式( CustomNotifyStyle)
CustomNotifyStyle style new CustomNotifyStyle ();#if UNITY_IPHONE
style.setType(CustomNotifyStyle.AuthorizationType.Badge | CustomNotifyStyle.AuthorizationType.Sound | CustomNotifyStyle.AuthorizationType.Alert);#elif UNITY_ANDROIDstyle.setContent (Content);
style.setTitle (Title);
style.setTickerText (TickerText);#endif
mobPush.setCustomNotification(style);获取注册ID (getRegistrationId)
mobPush.getRegistrationId();添加标签 (addTags)
String[] tags { tags1, tags2, tags3 };
mobPush.addTags(tags);获取标签 (getTags)
mobPush.getTags();删除标签 (deleteTags)
String[] tags { tags1, tags2, tags3 };
mobPush.deleteTags(tags);清除全部标签 (cleanAllTags )
mobPush.cleanAllTags();添加别名 (addAlias)
mobPush.addAlias(alias);获取别名 (getAlias)
mobPush.getAlias();清除别名 (cleanAllAlias)
mobPush.cleanAllAlias();停止通知服务 (stopPush)
mobPush.stopPush();重启通知服务 (restartPush)
mobPush.restartPush();判断通知是否被停止返回值bool类型(isPushStopped)
mobPush.isPushStopped();点击通知后是否打开应用首页setClickNotificationToLaunchPage
mobPush.setClickNotificationToLaunchPage(false);添加混淆配置
为了防止二次混淆MobPush需要在项目混淆文件中添加
-keep class com.mob.**{*;}-dontwarn com.mob.**如果同时集成了华为、小米、魅族等渠道推送同时也需要在项目中添加防二次混淆配置
-keep class com.huawei.**{*;}-keep class com.meizu.**{*;}-keep class com.xiaomi.**{*;}-keep class android.os.SystemProperties