帮助与文档

> >

 

本插件是基于MobPushCococs2dx进行插件扩充支持。目的是方便Cococs2dx开发者更方便地集成使用MobPush

当前支持的 MobPush 版本

  • iOS
  • Android v1.2.0

集成文档

下载并导入MobPush

下载MobPush-For-cocos2dx,下载完成后打开项目,将/Classes/C2DXMobPush文件夹复制到您的cocos2dx项目/Classes目录下

Android端接入

  1. 导入c2dxbridge Module到您的项目中(目录proj.android-studio\c2dxbridge), 并依赖此module。
  2. 在您的Android.mk文件中加入对c2dxbridge module的jni部分(Android.mk文件)的引用,即是引入mobpush_bridge静态库。在您的Android.mk文件中添加如下代码: 编译需要的cpp源代码(Android.mk)
$(call import-add-path,$(LOCAL_PATH)/../../c2dxbridge)
  1. Android.mk文件中添加编译需要的cpp源代码
../../../Classes/C2DXMobPush/C2DXMobPush.cpp \
../../../Classes/C2DXMobPush/C2DXMobPushCustomNotification.cpp \
../../../Classes/C2DXMobPush/C2DXMobPushLocalNotification.cpp \
../../../Classes/C2DXMobPush/Android/C2DXAndroidMobPush.cpp \
../../../Classes/C2DXMobPush/Android/C2DXAndroidCallback.cpp \
../../../Classes/C2DXMobPush/Android/C2DXAndroidSReqCallback.cpp \
../../../Classes/C2DXMobPush/Android/C2DXAndroidMobPushReceiver.cpp \
../../../Classes/C2DXMobPush/Android/com_mob_mobpush_cocos2dx_MobPushCallback.cpp \
../../../Classes/C2DXMobPush/Android/com_mob_mobpush_cocos2dx_MobPushSReqCallback.cpp \
../../../Classes/C2DXMobPush/Android/com_mob_mobpush_cocos2dx_MobPushReceiver.cpp \
../../../Classes/C2DXMobPush/Android/JSON/CCJSONConverter.cpp \
../../../Classes/C2DXMobPush/Android/JSON/cJSON/cJSON.c
  1. Android.mk文件中添加编译需要的头文件路径
$(LOCAL_PATH)/../../../Classes \
                    $(LOCAL_PATH)/../../../Classes/C2DXMobPush \
                    $(LOCAL_PATH)/../../../Classes/C2DXMobPush/Android \
                    $(LOCAL_PATH)/../../../Classes/C2DXMobPush/Android/JSON \
                    $(LOCAL_PATH)/../../../Classes/C2DXMobPush/Android/JSON/cJSON

如果您不太明白怎么复制这三行配置,可以去参考demo的Android.mk文件。

  1. 配置项目和应用build.gradle

在工程build.gradle中添加

buildscript {
    repositories {
        maven {
            url 'http://mvn.mob.com/android'
        }
    }
    dependencies {
        classpath 'com.mob.sdk:MobSDK:+'
    }
}

应用build.gradle中添加

apply plugin: 'com.mob.sdk'
MobSDK {
    appKey "您的appkey"
    appSecret "您的appSecret"

    MobGUI(true)
    MobPush {
        devInfo {
            HUAWEI{
                appId "xxx"
            }

            MEIZU{
                appId "xxx"
                appKey "xxx"
            }

            XIAOMI{
                appId "xxx"
                appKey "xxx"
            }
        }
    }
}

MobPush API

1 다운로드.获取注册ID

C2DXMobPush::getRegistrationId(C2DXGetRegistrationIdResultEvent callback) {}

2 졸업증명서 다운로드.设置推送监听

C2DXMobPush::addPushReceiver() {}

3 다운로드.设置别名

C2DXMobPush::setAlias(const char *alias) {}

4 다운로드.获取当前设置的别名

C2DXMobPush::getAlias(){}

5 다운로드.删除别名

C2DXMobPush::clearAllAlias() {}

6.添加标签

C2DXMobPush::addTags(C2DXArray *tags){}

7 카티아 v5 r18 다운로드.获取标签集合

C2DXMobPush::getTags(){}

8.删除标签

C2DXMobPush::deleteTags(C2DXArray *tags){}

9 클론 시디 다운로드.清空标签

C2DXMobPush::clearAllTags(){}

10.添加本地通知

C2DXMobPush::addLocalNotification(C2DXMobPushLocalNotification *noti) {}

11 다운로드.模拟发送推送消息

C2DXMobPush::req(int type, const char *text, int space, const char *extras,C2DXReqResultEvent reqResultEvent) {}

12 다운로드.添加消息回调

C2DXMobPush::setC2DXMessageCallBack(C2DXMessageCallBack messageCallBack){}

13 다운로드.别名回调

C2DXMobPush::setC2DXAliasCallBack(C2DXAliasCallBack aliasCallBack){}

14.标签回调

C2DXMobPush::setC2DXTagsCallBack(C2DXTagsCallBack tagsCallBack){}

 

添加混淆配置

为了防止二次混淆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



-dontwarn com.huawei.**

-dontwarn com.meizu.**

-dontwarn com.xiaomi.**

-dontwarn android.os.SystemProperties

 

 

相关文档