├── AnalyticsUtil.js ├── PushUtil.js ├── README.md ├── ShareUtil.js ├── android ├── build.gradle ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── libs │ ├── umeng-analytics-7.5.3.jar │ ├── umeng-common-1.5.3.jar │ ├── umeng-share-QQ-simplify-6.9.2.jar │ ├── umeng-share-core-6.9.2.jar │ ├── umeng-share-sina-simplify-6.9.2.jar │ ├── umeng-share-sms-6.9.2.jar │ ├── umeng-share-wechat-simplify-6.9.2.jar │ ├── umeng-shareboard-widget-6.9.2.jar │ ├── umeng-sharetool-6.9.2.jar │ └── utdid4all-1.1.5.3_proguard.jar ├── proguard-rules.pro ├── push │ ├── AndroidManifest.xml │ ├── build.gradle │ ├── libs │ │ ├── alicloud-android-sdk-httpdns-1.0.7.jar │ │ ├── armeabi-v7a │ │ │ ├── libcocklogic-1.1.3.so │ │ │ └── libtnet-3.1.11.so │ │ ├── umeng-push-3.3.3.jar │ │ └── x86 │ │ │ ├── libcocklogic-1.1.3.so │ │ │ └── libtnet-3.1.11.so │ ├── project.properties │ └── res │ │ ├── layout │ │ └── upush_notification.xml │ │ └── values │ │ └── string.xml └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── dk │ │ └── umeng │ │ ├── AnalyticsModule.java │ │ ├── DplusReactPackage.java │ │ ├── PushApplication.java │ │ ├── PushModule.java │ │ ├── RNUMConfigure.java │ │ └── ShareModule.java │ └── res │ ├── drawable │ ├── umeng_socialize_back_icon.png │ ├── umeng_socialize_btn_bg.xml │ ├── umeng_socialize_copy.png │ ├── umeng_socialize_copyurl.png │ ├── umeng_socialize_delete.png │ ├── umeng_socialize_edit_bg.xml │ ├── umeng_socialize_fav.png │ ├── umeng_socialize_menu_default.png │ ├── umeng_socialize_more.png │ ├── umeng_socialize_qq.png │ ├── umeng_socialize_qzone.png │ ├── umeng_socialize_share_music.png │ ├── umeng_socialize_share_video.png │ ├── umeng_socialize_share_web.png │ ├── umeng_socialize_sina.png │ ├── umeng_socialize_sms.png │ ├── umeng_socialize_wechat.png │ └── umeng_socialize_wxcircle.png │ ├── layout │ ├── socialize_share_menu_item.xml │ ├── umeng_socialize_oauth_dialog.xml │ └── umeng_socialize_share.xml │ └── values │ ├── umeng_socialize_shareview_strings.xml │ └── umeng_socialize_style.xml ├── index.js ├── ios ├── RNUMCommon.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist └── RNUMCommon │ ├── RNUMConfigure.h │ ├── RNUMConfigure.m │ ├── UMAnalytics │ ├── DplusMobClick.h │ ├── MobClick.h │ ├── MobClickGameAnalytics.h │ └── UMAnalytics │ ├── UMAnalyticsModule.h │ ├── UMAnalyticsModule.m │ ├── UMCommon │ ├── UMCommon.a │ ├── UMCommon.h │ └── UMConfigure.h │ ├── UMPush │ ├── UMPush │ └── UMessage.h │ ├── UMPushModule.h │ ├── UMPushModule.m │ ├── UMShare │ ├── SocialLibraries │ │ ├── QQ │ │ │ ├── UMSocialQQHandler.h │ │ │ └── libSocialQQ.a │ │ ├── Sina │ │ │ ├── UMSocialSinaHandler.h │ │ │ └── libSocialSina.a │ │ └── WeChat │ │ │ ├── UMSocialWechatHandler.h │ │ │ └── libSocialWeChat.a │ ├── UMCommonLogMacros.h │ ├── UMShare │ ├── UMShare.h │ ├── UMSocialCoreImageUtils.h │ ├── UMSocialDataManager.h │ ├── UMSocialGlobal.h │ ├── UMSocialHandler.h │ ├── UMSocialImageUtil.h │ ├── UMSocialManager.h │ ├── UMSocialMessageObject.h │ ├── UMSocialPlatformConfig.h │ ├── UMSocialPlatformProvider.h │ ├── UMSocialResponse.h │ ├── UMSocialWarterMarkConfig.h │ └── UMSociallogMacros.h │ ├── UMShareModule.h │ ├── UMShareModule.m │ ├── pushListener.h │ └── pushListener.m └── package.json /AnalyticsUtil.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by wangfei on 17/8/30. 3 | */ 4 | var { NativeModules } = require('react-native'); 5 | module.exports = NativeModules.UMAnalyticsModule; -------------------------------------------------------------------------------- /PushUtil.js: -------------------------------------------------------------------------------- 1 | import { 2 | NativeModules, 3 | Platform, 4 | DeviceEventEmitter, 5 | NativeEventEmitter, 6 | AppState 7 | } from 'react-native'; 8 | 9 | const UMPushModule = NativeModules.UMPushModule; 10 | const pushListener = new NativeEventEmitter(NativeModules.pushListener); 11 | 12 | let UMPush = { 13 | getDeviceToken() { 14 | return UMPushModule.getDeviceToken(); 15 | }, 16 | 17 | didReceiveMessage() { 18 | return new Promise((resolve, reject) => { 19 | this.addEventListener('didReceiveMessage', message => { 20 | //处于后台时,拦截收到的消息 21 | if (AppState.currentState === 'background') { 22 | return; 23 | } 24 | resolve(message); 25 | }); 26 | }); 27 | }, 28 | 29 | didOpenMessage() { 30 | return new Promise((resolve, reject) => { 31 | this.addEventListener('didOpenMessage', message => { 32 | resolve(message); 33 | }); 34 | }); 35 | }, 36 | 37 | addEventListener(eventName, handler) { 38 | if (Platform.OS === 'android') { 39 | return DeviceEventEmitter.addListener(eventName, event => { 40 | handler(event); 41 | }); 42 | } else { 43 | return pushListener.addListener(eventName, event => { 44 | handler(event); 45 | }); 46 | } 47 | } 48 | }; 49 | 50 | module.exports = UMPush; 51 | -------------------------------------------------------------------------------- /ShareUtil.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by wangfei on 17/8/28. 3 | */ 4 | var { NativeModules } = require('react-native'); 5 | module.exports = NativeModules.UMShareModule; 6 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion 23 5 | buildToolsVersion "23.0.1" 6 | 7 | defaultConfig { 8 | minSdkVersion 16 9 | targetSdkVersion 23 10 | versionCode 1 11 | versionName "1.0" 12 | 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | sourceSets.main { 21 | jniLibs.srcDirs = ['libs'] 22 | } 23 | } 24 | 25 | dependencies { 26 | compile fileTree(dir: 'libs', include: ['*.jar']) 27 | compile 'com.android.support:appcompat-v7:23.0.1' 28 | compile 'com.facebook.react:react-native:+' 29 | compile project(':push') 30 | } 31 | -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yolinsoft/react-native-dk-umeng/d7fda29c2ba35bc40f06e6ae3702245ed784d175/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Jun 11 17:51:37 CST 2018 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip 7 | -------------------------------------------------------------------------------- /android/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS="" 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn () { 37 | echo "$*" 38 | } 39 | 40 | die () { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Escape application args 158 | save () { 159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 160 | echo " " 161 | } 162 | APP_ARGS=$(save "$@") 163 | 164 | # Collect all arguments for the java command, following the shell quoting and substitution rules 165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 166 | 167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 169 | cd "$(dirname "$0")" 170 | fi 171 | 172 | exec "$JAVACMD" "$@" 173 | -------------------------------------------------------------------------------- /android/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /android/libs/umeng-analytics-7.5.3.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yolinsoft/react-native-dk-umeng/d7fda29c2ba35bc40f06e6ae3702245ed784d175/android/libs/umeng-analytics-7.5.3.jar -------------------------------------------------------------------------------- /android/libs/umeng-common-1.5.3.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yolinsoft/react-native-dk-umeng/d7fda29c2ba35bc40f06e6ae3702245ed784d175/android/libs/umeng-common-1.5.3.jar -------------------------------------------------------------------------------- /android/libs/umeng-share-QQ-simplify-6.9.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yolinsoft/react-native-dk-umeng/d7fda29c2ba35bc40f06e6ae3702245ed784d175/android/libs/umeng-share-QQ-simplify-6.9.2.jar -------------------------------------------------------------------------------- /android/libs/umeng-share-core-6.9.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yolinsoft/react-native-dk-umeng/d7fda29c2ba35bc40f06e6ae3702245ed784d175/android/libs/umeng-share-core-6.9.2.jar -------------------------------------------------------------------------------- /android/libs/umeng-share-sina-simplify-6.9.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yolinsoft/react-native-dk-umeng/d7fda29c2ba35bc40f06e6ae3702245ed784d175/android/libs/umeng-share-sina-simplify-6.9.2.jar -------------------------------------------------------------------------------- /android/libs/umeng-share-sms-6.9.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yolinsoft/react-native-dk-umeng/d7fda29c2ba35bc40f06e6ae3702245ed784d175/android/libs/umeng-share-sms-6.9.2.jar -------------------------------------------------------------------------------- /android/libs/umeng-share-wechat-simplify-6.9.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yolinsoft/react-native-dk-umeng/d7fda29c2ba35bc40f06e6ae3702245ed784d175/android/libs/umeng-share-wechat-simplify-6.9.2.jar -------------------------------------------------------------------------------- /android/libs/umeng-shareboard-widget-6.9.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yolinsoft/react-native-dk-umeng/d7fda29c2ba35bc40f06e6ae3702245ed784d175/android/libs/umeng-shareboard-widget-6.9.2.jar -------------------------------------------------------------------------------- /android/libs/umeng-sharetool-6.9.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yolinsoft/react-native-dk-umeng/d7fda29c2ba35bc40f06e6ae3702245ed784d175/android/libs/umeng-sharetool-6.9.2.jar -------------------------------------------------------------------------------- /android/libs/utdid4all-1.1.5.3_proguard.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yolinsoft/react-native-dk-umeng/d7fda29c2ba35bc40f06e6ae3702245ed784d175/android/libs/utdid4all-1.1.5.3_proguard.jar -------------------------------------------------------------------------------- /android/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/lcg/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /android/push/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 41 | 42 | 43 | 44 | 45 | 46 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 78 | 79 | 82 | 83 | 84 | 85 | 86 | 87 | 91 | 92 | 93 | 94 | 95 | 96 | 100 | 101 | 102 | 103 | 104 | 105 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 122 | 123 | 124 | 125 | 126 | 127 | 130 | 131 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 154 | 155 | 159 | 160 | 161 | 162 | 163 | 164 | -------------------------------------------------------------------------------- /android/push/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion 26 5 | buildToolsVersion '25.0.2' 6 | 7 | defaultConfig { 8 | minSdkVersion 11 9 | targetSdkVersion 25 10 | } 11 | 12 | buildTypes { 13 | release { 14 | minifyEnabled false 15 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' 16 | } 17 | debug { 18 | minifyEnabled false 19 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' 20 | } 21 | } 22 | 23 | sourceSets { 24 | main { 25 | manifest.srcFile 'AndroidManifest.xml' 26 | java.srcDirs = ['src'] 27 | resources.srcDirs = ['src'] 28 | aidl.srcDirs = ['src'] 29 | renderscript.srcDirs = ['src'] 30 | res.srcDirs = ['res'] 31 | assets.srcDirs = ['assets'] 32 | jniLibs.srcDirs = ['libs'] 33 | } 34 | 35 | // Move the tests to tests/java, tests/res, etc... 36 | instrumentTest.setRoot('tests') 37 | 38 | // Move the build types to build-types/ 39 | // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ... 40 | // This moves them out of them default location under src//... which would 41 | // conflict with src/ being used by the main source set. 42 | // Adding new build types or product flavors should be accompanied 43 | // by a similar customization. 44 | debug.setRoot('build-types/debug') 45 | release.setRoot('build-types/release') 46 | } 47 | 48 | android { 49 | lintOptions { 50 | abortOnError false 51 | } 52 | } 53 | } 54 | 55 | dependencies { 56 | compile fileTree(dir: 'libs', include: ['*.jar']) 57 | } 58 | -------------------------------------------------------------------------------- /android/push/libs/alicloud-android-sdk-httpdns-1.0.7.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yolinsoft/react-native-dk-umeng/d7fda29c2ba35bc40f06e6ae3702245ed784d175/android/push/libs/alicloud-android-sdk-httpdns-1.0.7.jar -------------------------------------------------------------------------------- /android/push/libs/armeabi-v7a/libcocklogic-1.1.3.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yolinsoft/react-native-dk-umeng/d7fda29c2ba35bc40f06e6ae3702245ed784d175/android/push/libs/armeabi-v7a/libcocklogic-1.1.3.so -------------------------------------------------------------------------------- /android/push/libs/armeabi-v7a/libtnet-3.1.11.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yolinsoft/react-native-dk-umeng/d7fda29c2ba35bc40f06e6ae3702245ed784d175/android/push/libs/armeabi-v7a/libtnet-3.1.11.so -------------------------------------------------------------------------------- /android/push/libs/umeng-push-3.3.3.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yolinsoft/react-native-dk-umeng/d7fda29c2ba35bc40f06e6ae3702245ed784d175/android/push/libs/umeng-push-3.3.3.jar -------------------------------------------------------------------------------- /android/push/libs/x86/libcocklogic-1.1.3.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yolinsoft/react-native-dk-umeng/d7fda29c2ba35bc40f06e6ae3702245ed784d175/android/push/libs/x86/libcocklogic-1.1.3.so -------------------------------------------------------------------------------- /android/push/libs/x86/libtnet-3.1.11.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yolinsoft/react-native-dk-umeng/d7fda29c2ba35bc40f06e6ae3702245ed784d175/android/push/libs/x86/libtnet-3.1.11.so -------------------------------------------------------------------------------- /android/push/project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system use, 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | 10 | # Project target. 11 | target=android-19 12 | android.library=true 13 | -------------------------------------------------------------------------------- /android/push/res/layout/upush_notification.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 13 | 14 | 19 | 20 | 31 | 32 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 60 | 61 | 66 | 67 | -------------------------------------------------------------------------------- /android/push/res/values/string.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /android/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /android/src/main/java/com/dk/umeng/AnalyticsModule.java: -------------------------------------------------------------------------------- 1 | package com.dk.umeng; 2 | 3 | import java.util.ArrayList; 4 | import java.util.HashMap; 5 | import java.util.List; 6 | import java.util.Map; 7 | 8 | 9 | import com.facebook.react.bridge.Callback; 10 | import com.facebook.react.bridge.ReactApplicationContext; 11 | import com.facebook.react.bridge.ReactContextBaseJavaModule; 12 | import com.facebook.react.bridge.ReactMethod; 13 | import com.facebook.react.bridge.ReadableArray; 14 | import com.facebook.react.bridge.ReadableMap; 15 | import com.facebook.react.bridge.ReadableMapKeySetIterator; 16 | import com.facebook.react.bridge.ReadableNativeMap; 17 | import com.facebook.react.bridge.ReadableType; 18 | import com.umeng.analytics.MobclickAgent; 19 | import com.umeng.analytics.dplus.UMADplus; 20 | import com.umeng.analytics.game.UMGameAgent; 21 | // import com.umeng.socialize.utils.Log; 22 | 23 | /** 24 | * Created by wangfei on 17/8/28. 25 | */ 26 | 27 | public class AnalyticsModule extends ReactContextBaseJavaModule { 28 | private ReactApplicationContext context; 29 | private boolean isGameInited = false; 30 | public AnalyticsModule(ReactApplicationContext reactContext) { 31 | super(reactContext); 32 | context = reactContext; 33 | } 34 | 35 | @Override 36 | public String getName() { 37 | return "UMAnalyticsModule"; 38 | } 39 | @ReactMethod 40 | private void initGame() { 41 | UMGameAgent.init(context); 42 | UMGameAgent.setPlayerLevel(1); 43 | MobclickAgent.setScenarioType(context, MobclickAgent.EScenarioType.E_UM_GAME); 44 | isGameInited = true; 45 | } 46 | /********************************U-App统计*********************************/ 47 | @ReactMethod 48 | public void onPageStart(String mPageName) { 49 | 50 | MobclickAgent.onPageStart(mPageName); 51 | 52 | } 53 | 54 | @ReactMethod 55 | public void onPageEnd(String mPageName) { 56 | 57 | MobclickAgent.onPageEnd(mPageName); 58 | 59 | } 60 | @ReactMethod 61 | public void onEvent(String eventId) { 62 | MobclickAgent.onEvent(context, eventId); 63 | } 64 | @ReactMethod 65 | public void onEventWithLable(String eventId,String eventLabel) { 66 | MobclickAgent.onEvent(context, eventId, eventLabel); 67 | } 68 | @ReactMethod 69 | public void onEventWithMap(String eventId,ReadableMap map) { 70 | Map rMap = new HashMap(); 71 | ReadableMapKeySetIterator iterator = map.keySetIterator(); 72 | while (iterator.hasNextKey()) { 73 | String key = iterator.nextKey(); 74 | if (ReadableType.Array == map.getType(key)) { 75 | rMap.put(key, map.getArray(key).toString()); 76 | } else if (ReadableType.Boolean == map.getType(key)) { 77 | rMap.put(key, String.valueOf(map.getBoolean(key))); 78 | } else if (ReadableType.Number == map.getType(key)) { 79 | rMap.put(key, String.valueOf(map.getInt(key))); 80 | } else if (ReadableType.String == map.getType(key)) { 81 | rMap.put(key, map.getString(key)); 82 | } else if (ReadableType.Map == map.getType(key)) { 83 | rMap.put(key, map.getMap(key).toString()); 84 | } 85 | } 86 | MobclickAgent.onEvent(context, eventId, rMap); 87 | } 88 | @ReactMethod 89 | public void onEventWithMapAndCount(String eventId,ReadableMap map,int value) { 90 | Map rMap = new HashMap(); 91 | ReadableMapKeySetIterator iterator = map.keySetIterator(); 92 | while (iterator.hasNextKey()) { 93 | String key = iterator.nextKey(); 94 | if (ReadableType.Array == map.getType(key)) { 95 | rMap.put(key, map.getArray(key).toString()); 96 | } else if (ReadableType.Boolean == map.getType(key)) { 97 | rMap.put(key, String.valueOf(map.getBoolean(key))); 98 | } else if (ReadableType.Number == map.getType(key)) { 99 | rMap.put(key, String.valueOf(map.getInt(key))); 100 | } else if (ReadableType.String == map.getType(key)) { 101 | rMap.put(key, map.getString(key)); 102 | } else if (ReadableType.Map == map.getType(key)) { 103 | rMap.put(key, map.getMap(key).toString()); 104 | } 105 | } 106 | MobclickAgent.onEventValue(context, eventId, rMap, value); 107 | } 108 | /********************************U-App(Game)统计*********************************/ 109 | @ReactMethod 110 | public void track(String eventName) { 111 | // Log.e("xxxxxx dddddd="+context); 112 | UMADplus.track(context,eventName); 113 | } 114 | @ReactMethod 115 | public void trackWithMap(String eventID,ReadableMap property) { 116 | Map map = new HashMap(); 117 | ReadableMapKeySetIterator iterator = property.keySetIterator(); 118 | while (iterator.hasNextKey()) { 119 | String key = iterator.nextKey(); 120 | if (ReadableType.Array == property.getType(key)) { 121 | map.put(key, property.getArray(key).toString()); 122 | } else if (ReadableType.Boolean == property.getType(key)) { 123 | map.put(key, String.valueOf(property.getBoolean(key))); 124 | } else if (ReadableType.Number == property.getType(key)) { 125 | map.put(key, String.valueOf(property.getInt(key))); 126 | } else if (ReadableType.String == property.getType(key)) { 127 | map.put(key, property.getString(key)); 128 | } else if (ReadableType.Map == property.getType(key)) { 129 | map.put(key, property.getMap(key).toString()); 130 | } 131 | } 132 | 133 | UMADplus.track(context, eventID, map); 134 | 135 | } 136 | @ReactMethod 137 | public void registerSuperProperty(ReadableMap map) { 138 | ReadableNativeMap map2 = (ReadableNativeMap) map; 139 | Map map3 = map2.toHashMap(); 140 | for (String key:map3.keySet()){ 141 | UMADplus.registerSuperProperty(context, key, map3.get(key)); 142 | } 143 | 144 | } 145 | @ReactMethod 146 | public void unregisterSuperProperty(String propertyName) { 147 | UMADplus.unregisterSuperProperty(context, propertyName); 148 | 149 | } 150 | @ReactMethod 151 | public void getSuperProperty(String propertyName, Callback callback) { 152 | try { 153 | String result = UMADplus.getSuperProperty(context, propertyName).toString(); 154 | callback.invoke(result); 155 | } catch (Exception e) { 156 | } 157 | 158 | } 159 | 160 | @ReactMethod 161 | public void getSuperProperties(Callback callback) { 162 | String result = UMADplus.getSuperProperties(context); 163 | callback.invoke(result); 164 | } 165 | @ReactMethod 166 | public void clearSuperProperties() { 167 | UMADplus.clearSuperProperties(context); 168 | 169 | } 170 | @ReactMethod 171 | public void setFirstLaunchEvent(ReadableArray array) { 172 | List list = new ArrayList(); 173 | for (int i = 0; i < array.size(); i++) { 174 | if (ReadableType.Array == array.getType(i)) { 175 | list.add(array.getArray(i).toString()); 176 | } else if (ReadableType.Boolean == array.getType(i)) { 177 | list.add(String.valueOf(array.getBoolean(i))); 178 | } else if (ReadableType.Number == array.getType(i)) { 179 | list.add(String.valueOf(array.getInt(i))); 180 | } else if (ReadableType.String == array.getType(i)) { 181 | list.add(array.getString(i)); 182 | } else if (ReadableType.Map == array.getType(i)) { 183 | list.add(array.getMap(i).toString()); 184 | } 185 | } 186 | UMADplus.setFirstLaunchEvent(context, list); 187 | } 188 | /********************************U-Dplus*********************************/ 189 | @ReactMethod 190 | public void profileSignInWithPUID(String puid) { 191 | MobclickAgent.onProfileSignIn(puid); 192 | } 193 | 194 | @ReactMethod 195 | @SuppressWarnings("unused") 196 | public void profileSignInWithPUIDWithProvider(String puid, String provider) { 197 | MobclickAgent.onProfileSignIn(puid, provider); 198 | } 199 | 200 | @ReactMethod 201 | @SuppressWarnings("unused") 202 | public void profileSignOff() { 203 | MobclickAgent.onProfileSignOff(); 204 | } 205 | 206 | @ReactMethod 207 | @SuppressWarnings("unused") 208 | public void setUserLevelId(int level) { 209 | if (!isGameInited) { 210 | initGame(); 211 | } 212 | UMGameAgent.setPlayerLevel(level); 213 | } 214 | 215 | @ReactMethod 216 | @SuppressWarnings("unused") 217 | public void startLevel(String level) { 218 | if (!isGameInited) { 219 | initGame(); 220 | } 221 | UMGameAgent.startLevel(level); 222 | } 223 | 224 | @ReactMethod 225 | @SuppressWarnings("unused") 226 | public void failLevel(String level) { 227 | if (!isGameInited) { 228 | initGame(); 229 | } 230 | UMGameAgent.failLevel(level); 231 | } 232 | 233 | @ReactMethod 234 | @SuppressWarnings("unused") 235 | public void finishLevel(String level) { 236 | if (!isGameInited) { 237 | initGame(); 238 | } 239 | UMGameAgent.finishLevel(level); 240 | } 241 | 242 | @ReactMethod 243 | @SuppressWarnings("unused") 244 | public void exchange(double currencyAmount, String currencyType, double virtualAmount, int channel, 245 | String orderId) { 246 | if (!isGameInited) { 247 | initGame(); 248 | } 249 | UMGameAgent.exchange(currencyAmount, currencyType, virtualAmount, channel, orderId); 250 | } 251 | 252 | @ReactMethod 253 | @SuppressWarnings("unused") 254 | public void pay(double money, double coin, int source) { 255 | if (!isGameInited) { 256 | initGame(); 257 | } 258 | UMGameAgent.pay(money, coin, source); 259 | } 260 | 261 | @ReactMethod 262 | @SuppressWarnings("unused") 263 | public void payWithItem(double money, String item, int number, double price, int source) { 264 | if (!isGameInited) { 265 | initGame(); 266 | } 267 | UMGameAgent.pay(money, item, number, price, source); 268 | } 269 | 270 | @ReactMethod 271 | @SuppressWarnings("unused") 272 | public void buy(String item, int number, double price) { 273 | if (!isGameInited) { 274 | initGame(); 275 | } 276 | UMGameAgent.buy(item, number, price); 277 | } 278 | 279 | @ReactMethod 280 | @SuppressWarnings("unused") 281 | public void use(String item, int number, double price) { 282 | if (!isGameInited) { 283 | initGame(); 284 | } 285 | UMGameAgent.use(item, number, price); 286 | } 287 | 288 | @ReactMethod 289 | @SuppressWarnings("unused") 290 | public void bonus(double coin, int source) { 291 | if (!isGameInited) { 292 | initGame(); 293 | } 294 | UMGameAgent.bonus(coin, source); 295 | } 296 | 297 | @ReactMethod 298 | @SuppressWarnings("unused") 299 | public void bonusWithItem(String item, int number, double price, int source) { 300 | if (!isGameInited) { 301 | initGame(); 302 | } 303 | UMGameAgent.bonus(item, number, price, source); 304 | } 305 | } 306 | -------------------------------------------------------------------------------- /android/src/main/java/com/dk/umeng/DplusReactPackage.java: -------------------------------------------------------------------------------- 1 | package com.dk.umeng; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Arrays; 5 | import java.util.Collections; 6 | import java.util.List; 7 | 8 | import com.facebook.react.ReactPackage; 9 | import com.facebook.react.bridge.JavaScriptModule; 10 | import com.facebook.react.bridge.NativeModule; 11 | import com.facebook.react.bridge.ReactApplicationContext; 12 | import com.facebook.react.shell.MainReactPackage; 13 | import com.facebook.react.uimanager.ViewManager; 14 | 15 | /** 16 | * Created by wangfei on 17/8/28. 17 | */ 18 | 19 | public class DplusReactPackage implements ReactPackage { 20 | 21 | @Override 22 | public List createViewManagers(ReactApplicationContext reactContext) { 23 | return Collections.emptyList(); 24 | } 25 | 26 | /** 27 | * 如需要添加本地方法,只需在这里add 28 | * 29 | * @param reactContext 30 | * @return 31 | */ 32 | @Override 33 | public List createNativeModules( 34 | ReactApplicationContext reactContext) { 35 | List modules = new ArrayList<>(); 36 | modules.add(new ShareModule(reactContext)); 37 | modules.add(new PushModule(reactContext)); 38 | modules.add(new AnalyticsModule(reactContext)); 39 | return modules; 40 | } 41 | } -------------------------------------------------------------------------------- /android/src/main/java/com/dk/umeng/PushApplication.java: -------------------------------------------------------------------------------- 1 | package com.dk.umeng; 2 | 3 | import android.app.Application; 4 | import android.app.Notification; 5 | import android.content.Context; 6 | import android.os.Handler; 7 | import android.util.Log; 8 | 9 | import com.umeng.message.IUmengRegisterCallback; 10 | import com.umeng.message.PushAgent; 11 | import com.umeng.message.UmengMessageHandler; 12 | import com.umeng.message.UmengNotificationClickHandler; 13 | import com.umeng.message.common.UmLog; 14 | import com.umeng.message.entity.UMessage; 15 | 16 | /** 17 | * Created by Magic on 2018/6/13. 18 | */ 19 | public class PushApplication extends Application { 20 | protected static final String TAG = PushModule.class.getSimpleName(); 21 | protected PushModule mPushModule; 22 | protected String mRegistrationId; 23 | protected PushAgent mPushAgent; 24 | //应用退出时,打开推送通知时临时保存的消息 25 | private UMessage tmpMessage; 26 | //应用退出时,打开推送通知时临时保存的事件 27 | private String tmpEvent; 28 | 29 | @Override 30 | public void onCreate() { 31 | super.onCreate(); 32 | enablePush(); 33 | } 34 | 35 | protected void setmPushModule(PushModule module) { 36 | mPushModule = module; 37 | if (tmpMessage != null && tmpEvent != null && mPushModule != null) { 38 | //execute the task 39 | clikHandlerSendEvent(tmpEvent, tmpMessage); 40 | //发送事件之后,清空临时内容 41 | tmpEvent = null; 42 | tmpMessage = null; 43 | } 44 | } 45 | 46 | //开启推送 47 | private void enablePush() { 48 | mPushAgent = PushAgent.getInstance(this); 49 | //注册推送服务 每次调用register都会回调该接口 50 | mPushAgent.register(new IUmengRegisterCallback() { 51 | @Override 52 | public void onSuccess(String deviceToken) { 53 | mRegistrationId = deviceToken; 54 | UmLog.i(TAG, "device token: " + deviceToken); 55 | } 56 | 57 | @Override 58 | public void onFailure(String s, String s1) { 59 | UmLog.i(TAG, "register failed: " + s + " " + s1); 60 | } 61 | }); 62 | 63 | //统计应用启动数据 64 | mPushAgent.onAppStart(); 65 | 66 | UmengNotificationClickHandler notificationClickHandler = new UmengNotificationClickHandler() { 67 | @Override 68 | public void launchApp(Context context, UMessage msg) { 69 | super.launchApp(context, msg); 70 | // Log.i(TAG, "launchApp"); 71 | clikHandlerSendEvent(PushModule.DidOpenMessage, msg); 72 | } 73 | 74 | @Override 75 | public void openUrl(Context context, UMessage msg) { 76 | super.openUrl(context, msg); 77 | clikHandlerSendEvent(PushModule.DidOpenMessage, msg); 78 | } 79 | 80 | @Override 81 | public void openActivity(Context context, UMessage msg) { 82 | super.openActivity(context, msg); 83 | clikHandlerSendEvent(PushModule.DidOpenMessage, msg); 84 | } 85 | 86 | @Override 87 | public void dealWithCustomAction(Context context, UMessage msg) { 88 | super.dealWithCustomAction(context, msg); 89 | clikHandlerSendEvent(PushModule.DidOpenMessage, msg); 90 | } 91 | }; 92 | 93 | //设置通知点击处理者 94 | mPushAgent.setNotificationClickHandler(notificationClickHandler); 95 | 96 | //设置消息和通知的处理 97 | mPushAgent.setMessageHandler(new UmengMessageHandler() { 98 | @Override 99 | public Notification getNotification(Context context, UMessage msg) { 100 | messageHandlerSendEvent(PushModule.DidReceiveMessage, msg); 101 | Log.i(TAG, msg.toString()); 102 | Log.i(TAG, "推送消息监听"); 103 | return super.getNotification(context, msg); 104 | } 105 | 106 | @Override 107 | public void dealWithCustomMessage(Context context, UMessage msg) { 108 | super.dealWithCustomMessage(context, msg); 109 | messageHandlerSendEvent(PushModule.DidReceiveMessage, msg); 110 | } 111 | }); 112 | 113 | //前台不显示通知 114 | // mPushAgent.setNotificaitonOnForeground(false); 115 | } 116 | 117 | /** 118 | * 点击推送通知触发的事件 119 | * @param event 120 | * @param msg 121 | */ 122 | private void clikHandlerSendEvent(final String event, final UMessage msg) { 123 | if(mPushModule == null) { 124 | tmpEvent = event; 125 | tmpMessage = msg; 126 | return; 127 | } 128 | //延时500毫秒发送推送,否则可能收不到 129 | new Handler().postDelayed(new Runnable() { 130 | public void run() { 131 | mPushModule.sendEvent(event, msg); 132 | } 133 | }, 500); 134 | } 135 | 136 | /** 137 | * 消息处理触发的事件 138 | * @param event 139 | * @param msg 140 | */ 141 | private void messageHandlerSendEvent(String event, UMessage msg) { 142 | if(mPushModule == null) { 143 | return; 144 | } 145 | mPushModule.sendEvent(event, msg); 146 | } 147 | } -------------------------------------------------------------------------------- /android/src/main/java/com/dk/umeng/PushModule.java: -------------------------------------------------------------------------------- 1 | package com.dk.umeng; 2 | 3 | import android.app.Activity; 4 | 5 | import java.util.HashMap; 6 | import java.util.Iterator; 7 | import java.util.List; 8 | import java.util.Map; 9 | 10 | import android.os.Handler; 11 | import android.os.Looper; 12 | import android.support.annotation.Nullable; 13 | import android.util.Log; 14 | import android.widget.Toast; 15 | import com.facebook.react.bridge.Arguments; 16 | import com.facebook.react.bridge.Callback; 17 | import com.facebook.react.bridge.LifecycleEventListener; 18 | import com.facebook.react.bridge.Promise; 19 | import com.facebook.react.bridge.ReactApplicationContext; 20 | import com.facebook.react.bridge.ReactContextBaseJavaModule; 21 | import com.facebook.react.bridge.ReactMethod; 22 | import com.facebook.react.bridge.WritableArray; 23 | import com.facebook.react.bridge.WritableMap; 24 | import com.facebook.react.modules.core.DeviceEventManagerModule; 25 | import com.umeng.message.MsgConstant; 26 | import com.umeng.message.PushAgent; 27 | import com.umeng.message.UTrack; 28 | import com.umeng.message.common.UmengMessageDeviceConfig; 29 | import com.umeng.message.common.inter.ITagManager; 30 | import com.umeng.message.entity.UMessage; 31 | import com.umeng.message.tag.TagManager; 32 | 33 | import org.json.JSONObject; 34 | 35 | /** 36 | * Created by wangfei on 17/8/30 37 | */ 38 | 39 | public class PushModule extends ReactContextBaseJavaModule implements LifecycleEventListener { 40 | private final int SUCCESS = 200; 41 | private final int ERROR = 0; 42 | private final int CANCEL = -1; 43 | 44 | protected static final String TAG = PushModule.class.getSimpleName(); 45 | protected static final String DidReceiveMessage = "didReceiveMessage"; 46 | protected static final String DidOpenMessage = "didOpenMessage"; 47 | 48 | private static Handler mSDKHandler = new Handler(Looper.getMainLooper()); 49 | private ReactApplicationContext context; 50 | private boolean isGameInited = false; 51 | private static Activity ma; 52 | private PushAgent mPushAgent; 53 | private Handler handler; 54 | private PushApplication mPushApplication; 55 | 56 | public PushModule(ReactApplicationContext reactContext) { 57 | super(reactContext); 58 | context = reactContext; 59 | //设置module给application 60 | PushApplication application = (PushApplication)reactContext.getBaseContext(); 61 | mPushApplication = application; 62 | //添加监听 63 | context.addLifecycleEventListener(this); 64 | mPushAgent = PushAgent.getInstance(context); 65 | } 66 | 67 | public static void initPushSDK(Activity activity) { 68 | ma = activity; 69 | } 70 | 71 | @Override 72 | public String getName() { 73 | return "UMPushModule"; 74 | } 75 | 76 | @Override 77 | public Map getConstants() { 78 | final Map constants = new HashMap<>(); 79 | constants.put(DidReceiveMessage, DidReceiveMessage); 80 | constants.put(DidOpenMessage, DidOpenMessage); 81 | return constants; 82 | } 83 | 84 | private static void runOnMainThread(Runnable runnable) { 85 | mSDKHandler.postDelayed(runnable, 0); 86 | } 87 | 88 | @ReactMethod 89 | public void addTag(String tag, final Callback successCallback) { 90 | mPushAgent.getTagManager().addTags(new TagManager.TCallBack() { 91 | @Override 92 | public void onMessage(final boolean isSuccess, final ITagManager.Result result) { 93 | 94 | 95 | if (isSuccess) { 96 | successCallback.invoke(SUCCESS,result.remain); 97 | } else { 98 | successCallback.invoke(ERROR,0); 99 | } 100 | 101 | } 102 | }, tag); 103 | } 104 | 105 | @ReactMethod 106 | public void deleteTag(String tag, final Callback successCallback) { 107 | mPushAgent.getTagManager().deleteTags(new TagManager.TCallBack() { 108 | @Override 109 | public void onMessage(boolean isSuccess, final ITagManager.Result result) { 110 | Log.i(TAG, "isSuccess:" + isSuccess); 111 | if (isSuccess) { 112 | successCallback.invoke(SUCCESS,result.remain); 113 | } else { 114 | successCallback.invoke(ERROR,0); 115 | } 116 | } 117 | }, tag); 118 | } 119 | 120 | @ReactMethod 121 | public void listTag(final Callback successCallback) { 122 | mPushAgent.getTagManager().getTags(new TagManager.TagListCallBack() { 123 | @Override 124 | public void onMessage(final boolean isSuccess, final List result) { 125 | mSDKHandler.post(new Runnable() { 126 | @Override 127 | public void run() { 128 | if (isSuccess) { 129 | if (result != null) { 130 | 131 | successCallback.invoke(SUCCESS,resultToList(result)); 132 | } else { 133 | successCallback.invoke(ERROR,resultToList(result)); 134 | } 135 | } else { 136 | successCallback.invoke(ERROR,resultToList(result)); 137 | } 138 | 139 | } 140 | }); 141 | 142 | } 143 | }); 144 | } 145 | 146 | @ReactMethod 147 | public void addAlias(String alias, String aliasType, final Callback successCallback) { 148 | mPushAgent.addAlias(alias, aliasType, new UTrack.ICallBack() { 149 | @Override 150 | public void onMessage(final boolean isSuccess, final String message) { 151 | Log.i(TAG, "isSuccess:" + isSuccess + "," + message); 152 | 153 | Log.e("xxxxxx","isuccess"+isSuccess); 154 | if (isSuccess) { 155 | successCallback.invoke(SUCCESS); 156 | } else { 157 | successCallback.invoke(ERROR); 158 | } 159 | 160 | 161 | } 162 | }); 163 | } 164 | 165 | @ReactMethod 166 | public void addAliasType() { 167 | Toast.makeText(ma,"function will come soon",Toast.LENGTH_LONG); 168 | } 169 | 170 | @ReactMethod 171 | public void addExclusiveAlias(String exclusiveAlias, String aliasType, final Callback successCallback) { 172 | mPushAgent.setAlias(exclusiveAlias, aliasType, new UTrack.ICallBack() { 173 | @Override 174 | public void onMessage(final boolean isSuccess, final String message) { 175 | 176 | Log.i(TAG, "isSuccess:" + isSuccess + "," + message); 177 | if (Boolean.TRUE.equals(isSuccess)) { 178 | successCallback.invoke(SUCCESS); 179 | }else { 180 | successCallback.invoke(ERROR); 181 | } 182 | 183 | 184 | 185 | } 186 | }); 187 | } 188 | 189 | @ReactMethod 190 | public void deleteAlias(String alias, String aliasType, final Callback successCallback) { 191 | mPushAgent.deleteAlias(alias, aliasType, new UTrack.ICallBack() { 192 | @Override 193 | public void onMessage(boolean isSuccess, String s) { 194 | if (Boolean.TRUE.equals(isSuccess)) { 195 | successCallback.invoke(SUCCESS); 196 | }else { 197 | successCallback.invoke(ERROR); 198 | } 199 | } 200 | }); 201 | } 202 | 203 | @ReactMethod 204 | public void appInfo(final Callback successCallback) { 205 | String pkgName = context.getPackageName(); 206 | String info = String.format("DeviceToken:%s\n" + "SdkVersion:%s\nAppVersionCode:%s\nAppVersionName:%s", 207 | mPushAgent.getRegistrationId(), MsgConstant.SDK_VERSION, 208 | UmengMessageDeviceConfig.getAppVersionCode(context), UmengMessageDeviceConfig.getAppVersionName(context)); 209 | successCallback.invoke("应用包名:" + pkgName + "\n" + info); 210 | } 211 | 212 | private WritableArray resultToList(List result){ 213 | WritableArray list = Arguments.createArray(); 214 | if (result!=null){ 215 | for (String key:result){ 216 | list.pushString(key); 217 | } 218 | } 219 | Log.e("xxxxxx","list="+list); 220 | return list; 221 | } 222 | 223 | private WritableMap convertToWriteMap(UMessage msg) { 224 | WritableMap map = Arguments.createMap(); 225 | //遍历Json 226 | JSONObject jsonObject = msg.getRaw(); 227 | Iterator keys = jsonObject.keys(); 228 | String key; 229 | while (keys.hasNext()) { 230 | key = keys.next(); 231 | try { 232 | map.putString(key, jsonObject.get(key).toString()); 233 | } 234 | catch (Exception e) { 235 | Log.e(TAG, "putString fail"); 236 | } 237 | } 238 | return map; 239 | } 240 | 241 | /* 242 | * 获取设备id 243 | */ 244 | @ReactMethod 245 | public void getDeviceToken(Promise promise) { 246 | String registrationId = mPushAgent.getRegistrationId(); 247 | promise.resolve(registrationId); 248 | } 249 | 250 | protected void sendEvent(String eventName, UMessage msg) { 251 | sendEvent(eventName, convertToWriteMap(msg)); 252 | } 253 | 254 | private void sendEvent(String eventName, @Nullable WritableMap params) { 255 | //此处需要添加hasActiveCatalystInstance,否则可能造成崩溃 256 | //问题解决参考: https://github.com/walmartreact/react-native-orientation-listener/issues/8 257 | if(context.hasActiveCatalystInstance()) { 258 | Log.i(TAG, "hasActiveCatalystInstance"); 259 | context.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class) 260 | .emit(eventName, params); 261 | } 262 | else { 263 | Log.i(TAG, "not hasActiveCatalystInstance"); 264 | } 265 | } 266 | 267 | @Override 268 | public void onHostResume() { 269 | mPushApplication.setmPushModule(this); 270 | } 271 | 272 | @Override 273 | public void onHostPause() { 274 | } 275 | 276 | @Override 277 | public void onHostDestroy() { 278 | mPushApplication.setmPushModule(null); 279 | } 280 | } -------------------------------------------------------------------------------- /android/src/main/java/com/dk/umeng/RNUMConfigure.java: -------------------------------------------------------------------------------- 1 | package com.dk.umeng; 2 | 3 | import java.lang.reflect.InvocationTargetException; 4 | import java.lang.reflect.Method; 5 | 6 | import android.annotation.TargetApi; 7 | import android.content.Context; 8 | import android.content.pm.ApplicationInfo; 9 | import android.content.pm.PackageManager; 10 | import android.os.Build.VERSION_CODES; 11 | import android.text.TextUtils; 12 | import android.util.Log; 13 | 14 | import com.umeng.commonsdk.UMConfigure; 15 | import com.umeng.commonsdk.statistics.common.MLog; 16 | 17 | /** 18 | * Created by wangfei on 17/9/14. 19 | */ 20 | 21 | public class RNUMConfigure { 22 | public static void init(Context context, String appkey, String channel, int type, String secret){ 23 | initRN("react-native","1.0"); 24 | if (TextUtils.isEmpty(secret)) { 25 | secret = getSecretByXML(context); 26 | } 27 | UMConfigure.init(context,appkey,channel,type,secret); 28 | } 29 | 30 | public static int getDeviceType(int num) { 31 | switch (num) { 32 | case 1: 33 | return UMConfigure.DEVICE_TYPE_PHONE; 34 | case 2: 35 | return UMConfigure.DEVICE_TYPE_BOX; 36 | default: 37 | return UMConfigure.DEVICE_TYPE_PHONE; 38 | 39 | } 40 | } 41 | 42 | public static void setLogEnabled(boolean enabled){ 43 | UMConfigure.setLogEnabled(enabled); 44 | } 45 | 46 | private static String getSecretByXML(Context context) { 47 | try { 48 | PackageManager manager = context.getPackageManager(); 49 | ApplicationInfo infoXml = manager.getApplicationInfo(context.getPackageName(), 128); 50 | if (infoXml != null) { 51 | String secret = infoXml.metaData.getString("UMENG_MESSAGE_SECRET"); 52 | if (secret != null) { 53 | return secret.trim(); 54 | } 55 | 56 | MLog.e("MobclickAgent", new Object[]{"getSecret failed. the applicationinfo is null!"}); 57 | } 58 | } catch (Throwable e) { 59 | MLog.e("MobclickAgent", "Could not read UMENG_MESSAGE_SECRET meta-data from AndroidManifest.xml.", e); 60 | } 61 | 62 | return null; 63 | } 64 | 65 | @TargetApi(VERSION_CODES.KITKAT) 66 | private static void initRN(String v, String t){ 67 | Method method = null; 68 | try { 69 | Class config = Class.forName("com.umeng.commonsdk.UMConfigure"); 70 | method = config.getDeclaredMethod("setWraperType", String.class, String.class); 71 | method.setAccessible(true); 72 | method.invoke(null, v,t); 73 | } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException | ClassNotFoundException e) { 74 | e.printStackTrace(); 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /android/src/main/java/com/dk/umeng/ShareModule.java: -------------------------------------------------------------------------------- 1 | package com.dk.umeng; 2 | 3 | import java.net.URLEncoder; 4 | import java.util.Map; 5 | 6 | import android.app.Activity; 7 | import android.os.Handler; 8 | import android.os.Looper; 9 | import android.text.TextUtils; 10 | import android.util.Log; 11 | import com.facebook.react.bridge.Arguments; 12 | import com.facebook.react.bridge.Callback; 13 | import com.facebook.react.bridge.Promise; 14 | import com.facebook.react.bridge.ReactApplicationContext; 15 | import com.facebook.react.bridge.ReactContextBaseJavaModule; 16 | import com.facebook.react.bridge.ReactMethod; 17 | import com.facebook.react.bridge.ReadableArray; 18 | import com.facebook.react.bridge.ReadableMap; 19 | import com.facebook.react.bridge.WritableMap; 20 | import com.umeng.commonsdk.framework.UMWorkDispatch; 21 | import com.umeng.socialize.PlatformConfig; 22 | import com.umeng.socialize.ShareAction; 23 | import com.umeng.socialize.UMAuthListener; 24 | import com.umeng.socialize.UMShareAPI; 25 | import com.umeng.socialize.UMShareListener; 26 | import com.umeng.socialize.bean.SHARE_MEDIA; 27 | import com.umeng.socialize.common.ResContainer; 28 | import com.umeng.socialize.media.UMImage; 29 | import com.umeng.socialize.media.UMWeb; 30 | 31 | /** 32 | * Created by wangfei on 17/8/28. 33 | */ 34 | 35 | public class ShareModule extends ReactContextBaseJavaModule { 36 | private static Activity ma; 37 | private final int SUCCESS = 200; 38 | private final int ERROR = 0; 39 | private final int CANCEL = -1; 40 | private static Handler mSDKHandler = new Handler(Looper.getMainLooper()); 41 | private ReactApplicationContext contect; 42 | public ShareModule(ReactApplicationContext reactContext) { 43 | super(reactContext); 44 | contect = reactContext; 45 | 46 | } 47 | public static void initSocialSDK(Activity activity){ 48 | ma = activity; 49 | } 50 | 51 | @Override 52 | public String getName() { 53 | return "UMShareModule"; 54 | } 55 | private static void runOnMainThread(Runnable runnable) { 56 | mSDKHandler.postDelayed(runnable, 0); 57 | } 58 | 59 | @ReactMethod 60 | public void setAccount(ReadableMap conf) { 61 | Integer type = conf.getInt("type"); 62 | String appId = conf.getString("appId"); 63 | String secret = conf.getString("secret"); 64 | String redirectUrl = ""; 65 | if(conf.hasKey("redirectURL")){ 66 | redirectUrl = conf.getString("redirectURL"); 67 | } 68 | switch (type){ 69 | case 0: 70 | PlatformConfig.setQQZone(appId, secret); 71 | case 1: 72 | PlatformConfig.setSinaWeibo(appId, secret, redirectUrl); 73 | case 2: 74 | PlatformConfig.setWeixin(appId, secret); 75 | default: 76 | PlatformConfig.setQQZone(appId, secret); 77 | } 78 | 79 | } 80 | 81 | @ReactMethod 82 | public void share(final ReadableMap msg, final Promise promise){ 83 | final String text = msg.getString("text"); 84 | final String img = msg.getString("image"); 85 | final String weburl = msg.getString("weburl"); 86 | final String title = msg.getString("title"); 87 | final int sharemedia = msg.getInt("sharemedia"); 88 | runOnMainThread(new Runnable() { 89 | @Override 90 | public void run() { 91 | 92 | if (!TextUtils.isEmpty(weburl)){ 93 | UMWeb web = new UMWeb(weburl); 94 | web.setTitle(title); 95 | web.setDescription(text); 96 | if (getImage(img)!=null){ 97 | web.setThumb(getImage(img)); 98 | } 99 | new ShareAction(ma).withText(text) 100 | .withMedia(web) 101 | .setPlatform(getShareMedia(sharemedia)) 102 | .setCallback(getUMShareListener(promise)) 103 | .share(); 104 | }else if (getImage(img)!=null){ 105 | new ShareAction(ma).withText(text) 106 | .withMedia(getImage(img)) 107 | .setPlatform(getShareMedia(sharemedia)) 108 | .setCallback(getUMShareListener(promise)) 109 | .share(); 110 | }else { 111 | new ShareAction(ma).withText(text) 112 | .setPlatform(getShareMedia(sharemedia)) 113 | .setCallback(getUMShareListener(promise)) 114 | .share(); 115 | } 116 | 117 | } 118 | }); 119 | 120 | } 121 | private UMShareListener getUMShareListener(final Promise promise){ 122 | return new UMShareListener() { 123 | @Override 124 | public void onStart(SHARE_MEDIA share_media) { 125 | 126 | } 127 | 128 | @Override 129 | public void onResult(SHARE_MEDIA share_media) { 130 | WritableMap result = Arguments.createMap(); 131 | result.putInt("code",SUCCESS); 132 | result.putString("message","success"); 133 | promise.resolve(result); 134 | } 135 | 136 | @Override 137 | public void onError(SHARE_MEDIA share_media, Throwable throwable) { 138 | String code = Integer.toString(ERROR); 139 | promise.reject(code,"error", throwable ); 140 | } 141 | 142 | @Override 143 | public void onCancel(SHARE_MEDIA share_media) { 144 | WritableMap result = Arguments.createMap(); 145 | result.putInt("code",CANCEL); 146 | result.putString("message","cancel"); 147 | promise.resolve(result); 148 | } 149 | }; 150 | } 151 | 152 | private UMImage getImage(String url){ 153 | if (TextUtils.isEmpty(url)){ 154 | return null; 155 | }else if(url.startsWith("http")){ 156 | return new UMImage(ma,url); 157 | }else if(url.startsWith("/")){ 158 | return new UMImage(ma,url); 159 | }else if(url.startsWith("res")){ 160 | return new UMImage(ma, ResContainer.getResourceId(ma,"drawable",url.replace("res/",""))); 161 | }else { 162 | return new UMImage(ma,url); 163 | } 164 | } 165 | @ReactMethod 166 | public void auth(final int sharemedia, final Promise promise){ 167 | runOnMainThread(new Runnable() { 168 | @Override 169 | public void run() { 170 | UMShareAPI.get(ma).getPlatformInfo(ma, getShareMedia(sharemedia), new UMAuthListener() { 171 | @Override 172 | public void onStart(SHARE_MEDIA share_media) { 173 | 174 | } 175 | 176 | @Override 177 | public void onComplete(SHARE_MEDIA share_media, int i, Map map) { 178 | WritableMap result = Arguments.createMap(); 179 | WritableMap res = Arguments.createMap(); 180 | for (String key:map.keySet()){ 181 | result.putString(key,map.get(key)); 182 | Log.e("todoremove","key="+key+" value"+map.get(key).toString()); 183 | } 184 | res.putInt("code", 0); 185 | res.putString("message", "success"); 186 | res.putMap("data", result); 187 | promise.resolve(res); 188 | } 189 | 190 | @Override 191 | public void onError(SHARE_MEDIA share_media, int i, Throwable throwable) { 192 | WritableMap result = Arguments.createMap(); 193 | promise.reject("1","error",throwable); 194 | } 195 | 196 | @Override 197 | public void onCancel(SHARE_MEDIA share_media, int i) { 198 | WritableMap result = Arguments.createMap(); 199 | WritableMap res = Arguments.createMap(); 200 | res.putInt("code",2); 201 | res.putString("message", "cancel"); 202 | res.putMap("data", result); 203 | promise.resolve(res); 204 | } 205 | }); 206 | } 207 | }); 208 | 209 | } 210 | 211 | @ReactMethod 212 | public void shareboard(final String text, final String img, final String weburl, final String title, final ReadableArray sharemedias, final Promise promise){ 213 | runOnMainThread(new Runnable() { 214 | @Override 215 | public void run() { 216 | 217 | if (!TextUtils.isEmpty(weburl)){ 218 | UMWeb web = new UMWeb(weburl); 219 | web.setTitle(title); 220 | web.setDescription(text); 221 | if (getImage(img)!=null){ 222 | web.setThumb(getImage(img)); 223 | } 224 | new ShareAction(ma).withText(text) 225 | .withMedia(web) 226 | .setDisplayList(getShareMedias(sharemedias)) 227 | .setCallback(getUMShareListener(promise)) 228 | .open(); 229 | }else if (getImage(img)!=null){ 230 | new ShareAction(ma).withText(text) 231 | .withMedia(getImage(img)) 232 | .setDisplayList(getShareMedias(sharemedias)) 233 | .setCallback(getUMShareListener(promise)) 234 | .open(); 235 | }else { 236 | new ShareAction(ma).withText(text) 237 | .setDisplayList(getShareMedias(sharemedias)) 238 | .setCallback(getUMShareListener(promise)) 239 | .open(); 240 | } 241 | 242 | } 243 | }); 244 | 245 | } 246 | private SHARE_MEDIA getShareMedia(int num){ 247 | switch (num){ 248 | case 0: 249 | return SHARE_MEDIA.QQ; 250 | 251 | case 1: 252 | return SHARE_MEDIA.SINA; 253 | 254 | case 2: 255 | return SHARE_MEDIA.WEIXIN; 256 | 257 | case 3: 258 | return SHARE_MEDIA.WEIXIN_CIRCLE; 259 | case 4: 260 | return SHARE_MEDIA.QZONE; 261 | case 5: 262 | return SHARE_MEDIA.EMAIL; 263 | case 6: 264 | return SHARE_MEDIA.SMS; 265 | case 7: 266 | return SHARE_MEDIA.FACEBOOK; 267 | case 8: 268 | return SHARE_MEDIA.TWITTER; 269 | case 9: 270 | return SHARE_MEDIA.WEIXIN_FAVORITE; 271 | case 10: 272 | return SHARE_MEDIA.GOOGLEPLUS; 273 | case 11: 274 | return SHARE_MEDIA.RENREN; 275 | case 12: 276 | return SHARE_MEDIA.TENCENT; 277 | case 13: 278 | return SHARE_MEDIA.DOUBAN; 279 | case 14: 280 | return SHARE_MEDIA.FACEBOOK_MESSAGER; 281 | case 15: 282 | return SHARE_MEDIA.YIXIN; 283 | case 16: 284 | return SHARE_MEDIA.YIXIN_CIRCLE; 285 | case 17: 286 | return SHARE_MEDIA.INSTAGRAM; 287 | case 18: 288 | return SHARE_MEDIA.PINTEREST; 289 | case 19: 290 | return SHARE_MEDIA.EVERNOTE; 291 | case 20: 292 | return SHARE_MEDIA.POCKET; 293 | case 21: 294 | return SHARE_MEDIA.LINKEDIN; 295 | case 22: 296 | return SHARE_MEDIA.FOURSQUARE; 297 | case 23: 298 | return SHARE_MEDIA.YNOTE; 299 | case 24: 300 | return SHARE_MEDIA.WHATSAPP; 301 | case 25: 302 | return SHARE_MEDIA.LINE; 303 | case 26: 304 | return SHARE_MEDIA.FLICKR; 305 | case 27: 306 | return SHARE_MEDIA.TUMBLR; 307 | case 28: 308 | return SHARE_MEDIA.ALIPAY; 309 | case 29: 310 | return SHARE_MEDIA.KAKAO; 311 | case 30: 312 | return SHARE_MEDIA.DROPBOX; 313 | case 31: 314 | return SHARE_MEDIA.VKONTAKTE; 315 | case 32: 316 | return SHARE_MEDIA.DINGTALK; 317 | case 33: 318 | return SHARE_MEDIA.MORE; 319 | default: 320 | return SHARE_MEDIA.QQ; 321 | } 322 | } 323 | private SHARE_MEDIA[] getShareMedias(ReadableArray num){ 324 | SHARE_MEDIA[] medias = new SHARE_MEDIA[num.size()]; 325 | for (int i = 0 ; i 2 | 4 | 5 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /android/src/main/res/drawable/umeng_socialize_copy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yolinsoft/react-native-dk-umeng/d7fda29c2ba35bc40f06e6ae3702245ed784d175/android/src/main/res/drawable/umeng_socialize_copy.png -------------------------------------------------------------------------------- /android/src/main/res/drawable/umeng_socialize_copyurl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yolinsoft/react-native-dk-umeng/d7fda29c2ba35bc40f06e6ae3702245ed784d175/android/src/main/res/drawable/umeng_socialize_copyurl.png -------------------------------------------------------------------------------- /android/src/main/res/drawable/umeng_socialize_delete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yolinsoft/react-native-dk-umeng/d7fda29c2ba35bc40f06e6ae3702245ed784d175/android/src/main/res/drawable/umeng_socialize_delete.png -------------------------------------------------------------------------------- /android/src/main/res/drawable/umeng_socialize_edit_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /android/src/main/res/drawable/umeng_socialize_fav.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yolinsoft/react-native-dk-umeng/d7fda29c2ba35bc40f06e6ae3702245ed784d175/android/src/main/res/drawable/umeng_socialize_fav.png -------------------------------------------------------------------------------- /android/src/main/res/drawable/umeng_socialize_menu_default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yolinsoft/react-native-dk-umeng/d7fda29c2ba35bc40f06e6ae3702245ed784d175/android/src/main/res/drawable/umeng_socialize_menu_default.png -------------------------------------------------------------------------------- /android/src/main/res/drawable/umeng_socialize_more.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yolinsoft/react-native-dk-umeng/d7fda29c2ba35bc40f06e6ae3702245ed784d175/android/src/main/res/drawable/umeng_socialize_more.png -------------------------------------------------------------------------------- /android/src/main/res/drawable/umeng_socialize_qq.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yolinsoft/react-native-dk-umeng/d7fda29c2ba35bc40f06e6ae3702245ed784d175/android/src/main/res/drawable/umeng_socialize_qq.png -------------------------------------------------------------------------------- /android/src/main/res/drawable/umeng_socialize_qzone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yolinsoft/react-native-dk-umeng/d7fda29c2ba35bc40f06e6ae3702245ed784d175/android/src/main/res/drawable/umeng_socialize_qzone.png -------------------------------------------------------------------------------- /android/src/main/res/drawable/umeng_socialize_share_music.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yolinsoft/react-native-dk-umeng/d7fda29c2ba35bc40f06e6ae3702245ed784d175/android/src/main/res/drawable/umeng_socialize_share_music.png -------------------------------------------------------------------------------- /android/src/main/res/drawable/umeng_socialize_share_video.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yolinsoft/react-native-dk-umeng/d7fda29c2ba35bc40f06e6ae3702245ed784d175/android/src/main/res/drawable/umeng_socialize_share_video.png -------------------------------------------------------------------------------- /android/src/main/res/drawable/umeng_socialize_share_web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yolinsoft/react-native-dk-umeng/d7fda29c2ba35bc40f06e6ae3702245ed784d175/android/src/main/res/drawable/umeng_socialize_share_web.png -------------------------------------------------------------------------------- /android/src/main/res/drawable/umeng_socialize_sina.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yolinsoft/react-native-dk-umeng/d7fda29c2ba35bc40f06e6ae3702245ed784d175/android/src/main/res/drawable/umeng_socialize_sina.png -------------------------------------------------------------------------------- /android/src/main/res/drawable/umeng_socialize_sms.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yolinsoft/react-native-dk-umeng/d7fda29c2ba35bc40f06e6ae3702245ed784d175/android/src/main/res/drawable/umeng_socialize_sms.png -------------------------------------------------------------------------------- /android/src/main/res/drawable/umeng_socialize_wechat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yolinsoft/react-native-dk-umeng/d7fda29c2ba35bc40f06e6ae3702245ed784d175/android/src/main/res/drawable/umeng_socialize_wechat.png -------------------------------------------------------------------------------- /android/src/main/res/drawable/umeng_socialize_wxcircle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yolinsoft/react-native-dk-umeng/d7fda29c2ba35bc40f06e6ae3702245ed784d175/android/src/main/res/drawable/umeng_socialize_wxcircle.png -------------------------------------------------------------------------------- /android/src/main/res/layout/socialize_share_menu_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 14 | 15 | 24 | 25 | -------------------------------------------------------------------------------- /android/src/main/res/layout/umeng_socialize_oauth_dialog.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 13 | 14 | 22 | 23 | 30 | 31 | 39 | 40 | 41 | 52 | 53 | 54 | 61 | 62 | 70 | 71 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 100 | 101 | 107 | 108 | 113 | 114 | 118 | 119 | 120 | 121 | -------------------------------------------------------------------------------- /android/src/main/res/layout/umeng_socialize_share.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 14 | 15 | 23 | 24 | 30 | 31 | 39 | 40 | 41 | 53 | 54 | 55 | 71 | 72 | 85 | 86 | 95 | 105 | 111 | 112 | 123 | 124 | 133 | 134 | 135 | 136 | 137 | -------------------------------------------------------------------------------- /android/src/main/res/values/umeng_socialize_shareview_strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 分享到新浪微博 4 | 分享到豆瓣 5 | 分享到人人网 6 | 7 | 分享到腾讯微博 8 | 分享到twitter 9 | 分享到领英 10 | -------------------------------------------------------------------------------- /android/src/main/res/values/umeng_socialize_style.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | import UMPush from './PushUtil'; 2 | import UMShare from './ShareUtil'; 3 | import UMAnalytics from './AnalyticsUtil'; 4 | 5 | module.exports = { 6 | UMPush, 7 | UMShare, 8 | UMAnalytics 9 | }; 10 | -------------------------------------------------------------------------------- /ios/RNUMCommon.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ios/RNUMCommon.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/RNUMCommon/RNUMConfigure.h: -------------------------------------------------------------------------------- 1 | // 2 | // RNUMConfigure.h 3 | // UMComponent 4 | // 5 | // Created by wyq.Cloudayc on 14/09/2017. 6 | // Copyright © 2017 Facebook. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface RNUMConfigure : NSObject 13 | 14 | + (void)initWithAppkey:(NSString *)appkey channel:(NSString *)channel; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /ios/RNUMCommon/RNUMConfigure.m: -------------------------------------------------------------------------------- 1 | // 2 | // RNUMConfigure.m 3 | // UMComponent 4 | // 5 | // Created by wyq.Cloudayc on 14/09/2017. 6 | // Copyright © 2017 Facebook. All rights reserved. 7 | // 8 | 9 | #import "RNUMConfigure.h" 10 | 11 | @implementation RNUMConfigure 12 | 13 | + (void)initWithAppkey:(NSString *)appkey channel:(NSString *)channel 14 | { 15 | SEL sel = NSSelectorFromString(@"setWraperType:wrapperVersion:"); 16 | if ([UMConfigure respondsToSelector:sel]) { 17 | [UMConfigure performSelector:sel withObject:@"react-native" withObject:@"1.0"]; 18 | } 19 | 20 | [UMConfigure initWithAppkey:appkey channel:channel]; 21 | } 22 | @end 23 | -------------------------------------------------------------------------------- /ios/RNUMCommon/UMAnalytics/DplusMobClick.h: -------------------------------------------------------------------------------- 1 | // 2 | // DplusMobClick.h 3 | // Analytics 4 | // 5 | // Copyright (C) 2010-2016 Umeng.com . All rights reserved. 6 | 7 | #import 8 | #import 9 | 10 | @interface DplusMobClick : NSObject 11 | 12 | /** Dplus增加事件 13 | @param eventName 事件名 14 | @param property 自定义属性 15 | */ 16 | +(void) track:(NSString *)eventName; 17 | +(void) track:(NSString *)eventName property:(NSDictionary *) property; 18 | 19 | /** 20 | * 设置属性 键值对 会覆盖同名的key 21 | * 将该函数指定的key-value写入dplus专用文件;APP启动时会自动读取该文件的所有key-value,并将key-value自动作为后续所有track事件的属性。 22 | */ 23 | +(void) registerSuperProperty:(NSDictionary *)property; 24 | 25 | /** 26 | * 27 | * 从dplus专用文件中删除指定key-value 28 | @param key 29 | */ 30 | +(void) unregisterSuperProperty:(NSString *)propertyName; 31 | 32 | /** 33 | * 34 | * 返回dplus专用文件中key对应的value;如果不存在,则返回空。 35 | @param key 36 | @return void 37 | */ 38 | +(NSString *)getSuperProperty:(NSString *)propertyName; 39 | 40 | /** 41 | * 返回Dplus专用文件中的所有key-value;如果不存在,则返回空。 42 | */ 43 | +(NSDictionary *)getSuperProperties; 44 | 45 | /** 46 | *清空Dplus专用文件中的所有key-value。 47 | */ 48 | +(void)clearSuperProperties; 49 | 50 | /** 51 | * 设置预置事件属性 键值对 会覆盖同名的key 52 | */ 53 | +(void) registerPreProperties:(NSDictionary *)property; 54 | 55 | /** 56 | * 57 | * 删除指定预置事件属性 58 | @param key 59 | */ 60 | +(void) unregisterPreProperty:(NSString *)propertyName; 61 | 62 | /** 63 | * 获取预置事件所有属性;如果不存在,则返回空。 64 | */ 65 | +(NSDictionary *)getPreProperties; 66 | 67 | /** 68 | *清空所有预置事件属性。 69 | */ 70 | +(void)clearPreProperties; 71 | 72 | 73 | /** 74 | * 设置关注事件是否首次触发,只关注eventList前五个合法eventID.只要已经保存五个,此接口无效 75 | */ 76 | +(void)setFirstLaunchEvent:(NSArray *)eventList; 77 | @end 78 | -------------------------------------------------------------------------------- /ios/RNUMCommon/UMAnalytics/MobClick.h: -------------------------------------------------------------------------------- 1 | // 2 | // MobClick.h 3 | // Analytics 4 | // 5 | // Copyright (C) 2010-2017 Umeng.com . All rights reserved. 6 | 7 | #import 8 | #import 9 | 10 | typedef void(^CallbackBlock)(); 11 | 12 | /** 13 | 统计的场景类别,默认为普通统计;若使用游戏统计API,则需选择游戏场景类别,如E_UM_GAME。 14 | */ 15 | typedef NS_ENUM (NSUInteger, eScenarioType) 16 | { 17 | E_UM_NORMAL = 0, // default value 18 | E_UM_GAME = 1, // game 19 | E_UM_DPLUS = 4 // DPlus 20 | }; 21 | 22 | @class CLLocation; 23 | @interface MobClick : NSObject 24 | 25 | #pragma mark basics 26 | 27 | ///--------------------------------------------------------------------------------------- 28 | /// @name 设置 29 | ///--------------------------------------------------------------------------------------- 30 | 31 | /** 设置 统计场景类型,默认为普通应用统计:E_UM_NORMAL 32 | @param 游戏统计必须设置为:E_UM_GAME. 33 | @return void. 34 | */ 35 | + (void)setScenarioType:(eScenarioType)eSType; 36 | 37 | /** 开启CrashReport收集, 默认YES(开启状态). 38 | @param value 设置为NO,可关闭友盟CrashReport收集功能. 39 | @return void. 40 | */ 41 | + (void)setCrashReportEnabled:(BOOL)value; 42 | 43 | #pragma mark event logs 44 | ///--------------------------------------------------------------------------------------- 45 | /// @name 页面计时 46 | ///--------------------------------------------------------------------------------------- 47 | 48 | /** 手动页面时长统计, 记录某个页面展示的时长. 49 | @param pageName 统计的页面名称. 50 | @param seconds 单位为秒,int型. 51 | @return void. 52 | */ 53 | + (void)logPageView:(NSString *)pageName seconds:(int)seconds; 54 | 55 | /** 自动页面时长统计, 开始记录某个页面展示时长. 56 | 使用方法:必须配对调用beginLogPageView:和endLogPageView:两个函数来完成自动统计,若只调用某一个函数不会生成有效数据。 57 | 在该页面展示时调用beginLogPageView:,当退出该页面时调用endLogPageView: 58 | @param pageName 统计的页面名称. 59 | @return void. 60 | */ 61 | + (void)beginLogPageView:(NSString *)pageName; 62 | 63 | /** 自动页面时长统计, 结束记录某个页面展示时长. 64 | 使用方法:必须配对调用beginLogPageView:和endLogPageView:两个函数来完成自动统计,若只调用某一个函数不会生成有效数据。 65 | 在该页面展示时调用beginLogPageView:,当退出该页面时调用endLogPageView: 66 | @param pageName 统计的页面名称. 67 | @return void. 68 | */ 69 | + (void)endLogPageView:(NSString *)pageName; 70 | 71 | 72 | ///--------------------------------------------------------------------------------------- 73 | /// @name 事件统计 74 | ///--------------------------------------------------------------------------------------- 75 | 76 | /** 自定义事件,数量统计. 77 | 使用前,请先到友盟App管理后台的设置->编辑自定义事件 中添加相应的事件ID,然后在工程中传入相应的事件ID 78 | 79 | @param eventId 网站上注册的事件Id. 80 | @param label 分类标签。不同的标签会分别进行统计,方便同一事件的不同标签的对比,为nil或空字符串时后台会生成和eventId同名的标签. 81 | @param accumulation 累加值。为减少网络交互,可以自行对某一事件ID的某一分类标签进行累加,再传入次数作为参数。 82 | @return void. 83 | */ 84 | + (void)event:(NSString *)eventId; //等同于 event:eventId label:eventId; 85 | /** 自定义事件,数量统计. 86 | 使用前,请先到友盟App管理后台的设置->编辑自定义事件 中添加相应的事件ID,然后在工程中传入相应的事件ID 87 | */ 88 | + (void)event:(NSString *)eventId label:(NSString *)label; // label为nil或@""时,等同于 event:eventId label:eventId; 89 | 90 | /** 自定义事件,数量统计. 91 | 使用前,请先到友盟App管理后台的设置->编辑自定义事件 中添加相应的事件ID,然后在工程中传入相应的事件ID 92 | */ 93 | + (void)event:(NSString *)eventId attributes:(NSDictionary *)attributes; 94 | 95 | + (void)event:(NSString *)eventId attributes:(NSDictionary *)attributes counter:(int)number; 96 | 97 | /** 自定义事件,时长统计. 98 | 使用前,请先到友盟App管理后台的设置->编辑自定义事件 中添加相应的事件ID,然后在工程中传入相应的事件ID. 99 | beginEvent,endEvent要配对使用,也可以自己计时后通过durations参数传递进来 100 | 101 | @param eventId 网站上注册的事件Id. 102 | @param label 分类标签。不同的标签会分别进行统计,方便同一事件的不同标签的对比,为nil或空字符串时后台会生成和eventId同名的标签. 103 | @param primarykey 这个参数用于和event_id一起标示一个唯一事件,并不会被统计;对于同一个事件在beginEvent和endEvent 中要传递相同的eventId 和 primarykey 104 | @param millisecond 自己计时需要的话需要传毫秒进来 105 | @return void. 106 | 107 | @warning 每个event的attributes不能超过10个 108 | eventId、attributes中key和value都不能使用空格和特殊字符,必须是NSString,且长度不能超过255个字符(否则将截取前255个字符) 109 | id, ts, du是保留字段,不能作为eventId及key的名称 110 | */ 111 | + (void)beginEvent:(NSString *)eventId; 112 | 113 | /** 自定义事件,时长统计. 114 | 使用前,请先到友盟App管理后台的设置->编辑自定义事件 中添加相应的事件ID,然后在工程中传入相应的事件ID. 115 | */ 116 | 117 | + (void)endEvent:(NSString *)eventId; 118 | /** 自定义事件,时长统计. 119 | 使用前,请先到友盟App管理后台的设置->编辑自定义事件 中添加相应的事件ID,然后在工程中传入相应的事件ID. 120 | */ 121 | 122 | + (void)beginEvent:(NSString *)eventId label:(NSString *)label; 123 | /** 自定义事件,时长统计. 124 | 使用前,请先到友盟App管理后台的设置->编辑自定义事件 中添加相应的事件ID,然后在工程中传入相应的事件ID. 125 | */ 126 | 127 | + (void)endEvent:(NSString *)eventId label:(NSString *)label; 128 | /** 自定义事件,时长统计. 129 | 使用前,请先到友盟App管理后台的设置->编辑自定义事件 中添加相应的事件ID,然后在工程中传入相应的事件ID. 130 | */ 131 | 132 | + (void)beginEvent:(NSString *)eventId primarykey :(NSString *)keyName attributes:(NSDictionary *)attributes; 133 | /** 自定义事件,时长统计. 134 | 使用前,请先到友盟App管理后台的设置->编辑自定义事件 中添加相应的事件ID,然后在工程中传入相应的事件ID. 135 | */ 136 | 137 | + (void)endEvent:(NSString *)eventId primarykey:(NSString *)keyName; 138 | /** 自定义事件,时长统计. 139 | 使用前,请先到友盟App管理后台的设置->编辑自定义事件 中添加相应的事件ID,然后在工程中传入相应的事件ID. 140 | */ 141 | 142 | + (void)event:(NSString *)eventId durations:(int)millisecond; 143 | /** 自定义事件,时长统计. 144 | 使用前,请先到友盟App管理后台的设置->编辑自定义事件 中添加相应的事件ID,然后在工程中传入相应的事件ID. 145 | */ 146 | 147 | + (void)event:(NSString *)eventId label:(NSString *)label durations:(int)millisecond; 148 | /** 自定义事件,时长统计. 149 | 使用前,请先到友盟App管理后台的设置->编辑自定义事件 中添加相应的事件ID,然后在工程中传入相应的事件ID. 150 | */ 151 | + (void)event:(NSString *)eventId attributes:(NSDictionary *)attributes durations:(int)millisecond; 152 | 153 | 154 | #pragma mark - user methods 155 | /** active user sign-in. 156 | 使用sign-In函数后,如果结束该PUID的统计,需要调用sign-Off函数 157 | @param puid : user's ID 158 | @param provider : 不能以下划线"_"开头,使用大写字母和数字标识; 如果是上市公司,建议使用股票代码。 159 | @return void. 160 | */ 161 | + (void)profileSignInWithPUID:(NSString *)puid; 162 | + (void)profileSignInWithPUID:(NSString *)puid provider:(NSString *)provider; 163 | 164 | /** active user sign-off. 165 | 停止sign-in PUID的统计 166 | @return void. 167 | */ 168 | + (void)profileSignOff; 169 | 170 | ///--------------------------------------------------------------------------------------- 171 | /// @name 地理位置设置 172 | /// 需要链接 CoreLocation.framework 并且 #import 173 | ///--------------------------------------------------------------------------------------- 174 | 175 | /** 设置经纬度信息 176 | @param latitude 纬度. 177 | @param longitude 经度. 178 | @return void 179 | */ 180 | + (void)setLatitude:(double)latitude longitude:(double)longitude; 181 | 182 | /** 设置经纬度信息 183 | @param location CLLocation 经纬度信息 184 | @return void 185 | */ 186 | + (void)setLocation:(CLLocation *)location; 187 | 188 | ///--------------------------------------------------------------------------------------- 189 | /// @name Utility函数 190 | ///--------------------------------------------------------------------------------------- 191 | 192 | /** 判断设备是否越狱,依据是否存在apt和Cydia.app 193 | */ 194 | + (BOOL)isJailbroken; 195 | 196 | /** 判断App是否被破解 197 | */ 198 | + (BOOL)isPirated; 199 | 200 | /** 设置 app secret 201 | @param secret string 202 | @return void. 203 | */ 204 | + (void)setSecret:(NSString *)secret; 205 | 206 | + (void)setCrashCBBlock:(CallbackBlock)cbBlock; 207 | 208 | /** DeepLink事件 209 | @param link 唤起应用的link 210 | @return void. 211 | */ 212 | + (void)onDeepLinkReceived:(NSURL *)link; 213 | 214 | @end 215 | -------------------------------------------------------------------------------- /ios/RNUMCommon/UMAnalytics/MobClickGameAnalytics.h: -------------------------------------------------------------------------------- 1 | // 2 | // MobClickGameAnalytics.h 3 | // Analytics 4 | // 5 | // Copyright (C) 2010-2014 Umeng.com . All rights reserved. 6 | 7 | @interface MobClickGameAnalytics : NSObject 8 | 9 | #pragma mark - account function 10 | /** active user sign-in. 11 | 使用sign-In函数后,如果结束该PUID的统计,需要调用sign-Off函数 12 | @param puid : user's ID 13 | @param provider : 不能以下划线"_"开头,使用大写字母和数字标识; 如果是上市公司,建议使用股票代码。 14 | @return void. 15 | */ 16 | + (void)profileSignInWithPUID:(NSString *)puid; 17 | + (void)profileSignInWithPUID:(NSString *)puid provider:(NSString *)provider; 18 | 19 | /** active user sign-off. 20 | 停止sign-in PUID的统计 21 | @return void. 22 | */ 23 | + (void)profileSignOff; 24 | 25 | #pragma mark GameLevel methods 26 | ///--------------------------------------------------------------------------------------- 27 | /// @name set game level 28 | ///--------------------------------------------------------------------------------------- 29 | 30 | /** 设置玩家的等级. 31 | */ 32 | 33 | /** 设置玩家等级属性. 34 | @param level 玩家等级 35 | @return void 36 | */ 37 | + (void)setUserLevelId:(int)level; 38 | 39 | ///--------------------------------------------------------------------------------------- 40 | /// @name 关卡统计 41 | ///--------------------------------------------------------------------------------------- 42 | 43 | /** 记录玩家进入关卡,通过关卡及失败的情况. 44 | */ 45 | 46 | 47 | /** 进入关卡. 48 | @param level 关卡 49 | @return void 50 | */ 51 | + (void)startLevel:(NSString *)level; 52 | 53 | /** 通过关卡. 54 | @param level 关卡,如果level == nil 则为当前关卡 55 | @return void 56 | */ 57 | + (void)finishLevel:(NSString *)level; 58 | 59 | /** 未通过关卡. 60 | @param level 关卡,如果level == nil 则为当前关卡 61 | @return void 62 | */ 63 | 64 | + (void)failLevel:(NSString *)level; 65 | 66 | 67 | #pragma mark - 68 | #pragma mark Pay methods 69 | 70 | ///--------------------------------------------------------------------------------------- 71 | /// @name 支付统计 72 | ///--------------------------------------------------------------------------------------- 73 | 74 | /** 记录玩家交易兑换货币的情况 75 | @param currencyAmount 现金或等价物总额 76 | @param currencyType 为ISO4217定义的3位字母代码,如CNY,USD等(如使用其它自定义等价物作为现金,可使用ISO4217中未定义的3位字母组合传入货币类型) 77 | @param virtualAmount 虚拟币数量 78 | @param channel 支付渠道 79 | @param orderId 交易订单ID 80 | @return void 81 | */ 82 | + (void)exchange:(NSString *)orderId currencyAmount:(double)currencyAmount currencyType:(NSString *)currencyType virtualCurrencyAmount:(double)virtualAmount paychannel:(int)channel; 83 | 84 | /** 玩家支付货币兑换虚拟币. 85 | @param cash 真实货币数量 86 | @param source 支付渠道 87 | @param coin 虚拟币数量 88 | @return void 89 | */ 90 | 91 | + (void)pay:(double)cash source:(int)source coin:(double)coin; 92 | 93 | /** 玩家支付货币购买道具. 94 | @param cash 真实货币数量 95 | @param source 支付渠道 96 | @param item 道具名称 97 | @param amount 道具数量 98 | @param price 道具单价 99 | @return void 100 | */ 101 | + (void)pay:(double)cash source:(int)source item:(NSString *)item amount:(int)amount price:(double)price; 102 | 103 | 104 | #pragma mark - 105 | #pragma mark Buy methods 106 | 107 | ///--------------------------------------------------------------------------------------- 108 | /// @name 虚拟币购买统计 109 | ///--------------------------------------------------------------------------------------- 110 | 111 | /** 记录玩家使用虚拟币的消费情况 112 | */ 113 | 114 | 115 | /** 玩家使用虚拟币购买道具 116 | @param item 道具名称 117 | @param amount 道具数量 118 | @param price 道具单价 119 | @return void 120 | */ 121 | + (void)buy:(NSString *)item amount:(int)amount price:(double)price; 122 | 123 | 124 | #pragma mark - 125 | #pragma mark Use methods 126 | 127 | 128 | ///--------------------------------------------------------------------------------------- 129 | /// @name 道具消耗统计 130 | ///--------------------------------------------------------------------------------------- 131 | 132 | /** 记录玩家道具消费情况 133 | */ 134 | 135 | 136 | /** 玩家使用虚拟币购买道具 137 | @param item 道具名称 138 | @param amount 道具数量 139 | @param price 道具单价 140 | @return void 141 | */ 142 | 143 | + (void)use:(NSString *)item amount:(int)amount price:(double)price; 144 | 145 | 146 | #pragma mark - 147 | #pragma mark Bonus methods 148 | 149 | 150 | ///--------------------------------------------------------------------------------------- 151 | /// @name 虚拟币及道具奖励统计 152 | ///--------------------------------------------------------------------------------------- 153 | 154 | /** 记录玩家获赠虚拟币及道具的情况 155 | */ 156 | 157 | 158 | /** 玩家获虚拟币奖励 159 | @param coin 虚拟币数量 160 | @param source 奖励方式 161 | @return void 162 | */ 163 | 164 | + (void)bonus:(double)coin source:(int)source; 165 | 166 | /** 玩家获道具奖励 167 | @param item 道具名称 168 | @param amount 道具数量 169 | @param price 道具单价 170 | @param source 奖励方式 171 | @return void 172 | */ 173 | 174 | + (void)bonus:(NSString *)item amount:(int)amount price:(double)price source:(int)source; 175 | 176 | #pragma mark DEPRECATED 177 | 178 | //已经被新的setUserLevelId:方法替代,请使用新的API。 179 | + (void)setUserLevel:(NSString *)level; 180 | 181 | //已经被新的active user方法替代,请使用新的API。 182 | + (void)setUserID:(NSString *)userId sex:(int)sex age:(int)age platform:(NSString *)platform; 183 | 184 | @end 185 | -------------------------------------------------------------------------------- /ios/RNUMCommon/UMAnalytics/UMAnalytics: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yolinsoft/react-native-dk-umeng/d7fda29c2ba35bc40f06e6ae3702245ed784d175/ios/RNUMCommon/UMAnalytics/UMAnalytics -------------------------------------------------------------------------------- /ios/RNUMCommon/UMAnalyticsModule.h: -------------------------------------------------------------------------------- 1 | // 2 | // analytics.h 3 | // analytics 4 | // 5 | // 6 | // Copyright (c) 2016年 tendcloud. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | @interface UMAnalyticsModule : NSObject 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /ios/RNUMCommon/UMAnalyticsModule.m: -------------------------------------------------------------------------------- 1 | // 2 | // analytics.m 3 | // analytics 4 | // 5 | // 6 | // Copyright (c) 2016年 tendcloud. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import 12 | #import "UMAnalyticsModule.h" 13 | #import 14 | #import 15 | 16 | @implementation UMAnalyticsModule 17 | 18 | RCT_EXPORT_MODULE(); 19 | 20 | 21 | RCT_EXPORT_METHOD(onEvent:(NSString *)eventId resolver:(RCTPromiseResolveBlock)resolve 22 | rejecter:(RCTPromiseRejectBlock)reject) 23 | { 24 | if (eventId == nil || [eventId isKindOfClass:[NSNull class]]) { 25 | reject(@"1",@"参数为空",nil); 26 | return; 27 | }else{ 28 | resolve(@(0)); 29 | } 30 | [MobClick event:eventId]; 31 | } 32 | 33 | RCT_EXPORT_METHOD(onEventWithLabel:(NSString *)eventId eventLabel:(NSString *)eventLabel resolver:(RCTPromiseResolveBlock)resolve 34 | rejecter:(RCTPromiseRejectBlock)reject) 35 | { 36 | if (eventId == nil || [eventId isKindOfClass:[NSNull class]]) { 37 | reject(@"1",@"参数为空",nil); 38 | return; 39 | }else{ 40 | resolve(@(0)); 41 | } 42 | if ([eventLabel isKindOfClass:[NSNull class]]) { 43 | eventLabel = nil; 44 | } 45 | [MobClick event:eventId label:eventLabel]; 46 | } 47 | 48 | RCT_EXPORT_METHOD(onEventWithMap:(NSString *)eventId parameters:(NSDictionary *)parameters) 49 | { 50 | if (eventId == nil || [eventId isKindOfClass:[NSNull class]]) { 51 | return; 52 | } 53 | if (parameters == nil && [parameters isKindOfClass:[NSNull class]]) { 54 | parameters = nil; 55 | } 56 | [MobClick event:eventId attributes:parameters]; 57 | } 58 | 59 | RCT_EXPORT_METHOD(onEventWithMapAndCount:(NSString *)eventId parameters:(NSDictionary *)parameters eventNum:(int)eventNum) 60 | { 61 | if (eventId == nil || [eventId isKindOfClass:[NSNull class]]) { 62 | return; 63 | } 64 | if (parameters == nil && [parameters isKindOfClass:[NSNull class]]) { 65 | parameters = nil; 66 | } 67 | 68 | [MobClick event:eventId attributes:parameters counter:eventNum]; 69 | } 70 | 71 | RCT_EXPORT_METHOD(onPageBegin:(NSString *)pageName) 72 | { 73 | if (pageName == nil || [pageName isKindOfClass:[NSNull class]]) { 74 | return; 75 | } 76 | [MobClick beginLogPageView:pageName]; 77 | } 78 | 79 | RCT_EXPORT_METHOD(onPageEnd:(NSString *)pageName) 80 | { 81 | if (pageName == nil || [pageName isKindOfClass:[NSNull class]]) { 82 | return; 83 | } 84 | [MobClick endLogPageView:pageName]; 85 | } 86 | 87 | RCT_EXPORT_METHOD(profileSignInWithPUID:(NSString *)puid) 88 | { 89 | if (puid == nil || [puid isKindOfClass:[NSNull class]]) { 90 | return; 91 | } 92 | [MobClick profileSignInWithPUID:puid]; 93 | } 94 | 95 | RCT_EXPORT_METHOD(profileSignInWithPUIDWithProvider:(NSString *)provider puid:(NSString *)puid) 96 | { 97 | if (provider == nil && [provider isKindOfClass:[NSNull class]]) { 98 | provider = nil; 99 | } 100 | if (puid == nil || [puid isKindOfClass:[NSNull class]]) { 101 | return; 102 | } 103 | 104 | [MobClick profileSignInWithPUID:puid provider:provider]; 105 | } 106 | 107 | RCT_EXPORT_METHOD(profileSignOff) 108 | { 109 | [MobClick profileSignOff]; 110 | } 111 | //游戏统计 112 | 113 | RCT_EXPORT_METHOD(setUserLevelId:(int)level) 114 | { 115 | [MobClickGameAnalytics setUserLevelId:level]; 116 | } 117 | 118 | RCT_EXPORT_METHOD(startLevel:(NSString *)level) 119 | { 120 | if (level == nil || [level isKindOfClass:[NSNull class]]) { 121 | return; 122 | } 123 | [MobClickGameAnalytics startLevel:level]; 124 | } 125 | 126 | RCT_EXPORT_METHOD(finishLevel:(NSString *)level) 127 | { 128 | if (level == nil || [level isKindOfClass:[NSNull class]]) { 129 | return; 130 | } 131 | [MobClickGameAnalytics finishLevel:level]; 132 | } 133 | 134 | RCT_EXPORT_METHOD(failLevel:(NSString *)level) 135 | { 136 | if (level == nil || [level isKindOfClass:[NSNull class]]) { 137 | return; 138 | } 139 | [MobClickGameAnalytics failLevel:level]; 140 | } 141 | 142 | RCT_EXPORT_METHOD(exchange:(double)currencyAmount currencyType:(NSString *)currencyType virtualAmount:(double)virtualAmount channel:(int)channel orderId:(NSString *)orderId) 143 | { 144 | if (currencyType == nil && [currencyType isKindOfClass:[NSNull class]]) { 145 | currencyType = nil; 146 | } 147 | if (orderId == nil || [orderId isKindOfClass:[NSNull class]]) { 148 | return; 149 | } 150 | [MobClickGameAnalytics exchange:orderId currencyAmount:currencyAmount currencyType:currencyType virtualCurrencyAmount:virtualAmount paychannel:channel]; 151 | } 152 | 153 | RCT_EXPORT_METHOD(pay:(double)cash coin:(int)coin source:(double)source) 154 | { 155 | [MobClickGameAnalytics pay:cash source:source coin:coin]; 156 | } 157 | 158 | RCT_EXPORT_METHOD(payWithItem:(double)cash item:(NSString *)item amount:(int)amount price:(double)price source:(int)source) 159 | { 160 | if (item == nil && [item isKindOfClass:[NSNull class]]) { 161 | item = nil; 162 | } 163 | [MobClickGameAnalytics pay:cash source:source item:item amount:amount price:price]; 164 | } 165 | 166 | RCT_EXPORT_METHOD(buy:(NSString *)item amount:(int)amount price:(double)price) 167 | { 168 | if (item == nil || [item isKindOfClass:[NSNull class]]) { 169 | return; 170 | } 171 | [MobClickGameAnalytics buy:item amount:amount price:price]; 172 | } 173 | 174 | RCT_EXPORT_METHOD(use:(NSString *)item amount:(int)amount price:(double)price) 175 | { 176 | if (item == nil || [item isKindOfClass:[NSNull class]]) { 177 | return; 178 | } 179 | [MobClickGameAnalytics use:item amount:amount price:price]; 180 | } 181 | 182 | RCT_EXPORT_METHOD(bonus:(double)coin source:(int)source) 183 | { 184 | [MobClickGameAnalytics bonus:coin source:source]; 185 | } 186 | 187 | RCT_EXPORT_METHOD(bonusWithItem:(NSString *)item amount:(int)amount price:(double)price source:(int)source) 188 | { 189 | if (item == nil || [item isKindOfClass:[NSNull class]]) { 190 | return; 191 | } 192 | [MobClickGameAnalytics bonus:item amount:amount price:price source:source]; 193 | } 194 | 195 | //Dplus 196 | 197 | RCT_EXPORT_METHOD(track:(NSString *)eventName) 198 | { 199 | 200 | if (eventName == nil && [eventName isKindOfClass:[NSNull class]]) { 201 | eventName = nil; 202 | } 203 | [DplusMobClick track:eventName]; 204 | } 205 | 206 | RCT_EXPORT_METHOD(trackWithMap:(NSString *)eventName property:(NSDictionary *) property) 207 | { 208 | 209 | if (eventName == nil && [eventName isKindOfClass:[NSNull class]]) { 210 | eventName = nil; 211 | } 212 | 213 | if (property == nil && [property isKindOfClass:[NSNull class]]) { 214 | property = nil; 215 | } 216 | [DplusMobClick track:eventName property:property]; 217 | } 218 | 219 | RCT_EXPORT_METHOD(registerSuperProperty:(NSDictionary *)property) 220 | { 221 | 222 | if (property == nil && [property isKindOfClass:[NSNull class]]) { 223 | property = nil; 224 | } 225 | [DplusMobClick registerSuperProperty:property]; 226 | } 227 | 228 | RCT_EXPORT_METHOD(unregisterSuperProperty:(NSString *)propertyName) 229 | { 230 | 231 | if (propertyName == nil && [propertyName isKindOfClass:[NSNull class]]) { 232 | propertyName = nil; 233 | } 234 | [DplusMobClick unregisterSuperProperty:propertyName]; 235 | 236 | } 237 | 238 | 239 | 240 | RCT_EXPORT_METHOD(getSuperProperty:(NSString *)propertyName callback:(RCTResponseSenderBlock)callback) 241 | { 242 | 243 | if (propertyName == nil && [propertyName isKindOfClass:[NSNull class]]) { 244 | propertyName = nil; 245 | } 246 | callback(@[[DplusMobClick getSuperProperty:propertyName]]); 247 | 248 | } 249 | 250 | RCT_EXPORT_METHOD(getSuperProperties:(RCTResponseSenderBlock)callback) 251 | { 252 | NSString *jsonString = nil; 253 | NSError *error = nil; 254 | NSData *jsonData = [NSJSONSerialization dataWithJSONObject:[DplusMobClick getSuperProperties] 255 | options:kNilOptions //TODO: NSJSONWritingPrettyPrinted // kNilOptions 256 | error:&error]; 257 | if ([jsonData length] && (error == nil)) 258 | { 259 | jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding] ; 260 | }else{ 261 | jsonString=@""; 262 | } 263 | 264 | callback(@[jsonString]); 265 | 266 | } 267 | 268 | RCT_EXPORT_METHOD(clearSuperProperties) 269 | { 270 | [DplusMobClick clearSuperProperties]; 271 | 272 | } 273 | 274 | RCT_EXPORT_METHOD(setFirstLaunchEvent:(NSArray *)eventList) 275 | { 276 | if (eventList == nil && [eventList isKindOfClass:[NSNull class]]) { 277 | eventList = nil; 278 | } 279 | [DplusMobClick setFirstLaunchEvent:eventList]; 280 | } 281 | 282 | @end 283 | -------------------------------------------------------------------------------- /ios/RNUMCommon/UMCommon/UMCommon.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yolinsoft/react-native-dk-umeng/d7fda29c2ba35bc40f06e6ae3702245ed784d175/ios/RNUMCommon/UMCommon/UMCommon.a -------------------------------------------------------------------------------- /ios/RNUMCommon/UMCommon/UMCommon.h: -------------------------------------------------------------------------------- 1 | // 2 | // UMCommon.h 3 | // UMCommon 4 | // 5 | // Created by San Zhang on 11/2/16. 6 | // Copyright © 2016 UMeng. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //! Project version number for UMCommon. 12 | FOUNDATION_EXPORT double UMCommonVersionNumber; 13 | 14 | //! Project version string for UMCommon. 15 | FOUNDATION_EXPORT const unsigned char UMCommonVersionString[]; 16 | 17 | // In this header, you should import all the public headers of your framework using statements like #import 18 | 19 | #import 20 | -------------------------------------------------------------------------------- /ios/RNUMCommon/UMCommon/UMConfigure.h: -------------------------------------------------------------------------------- 1 | // 2 | // UMConfigure.h 3 | // UMCommon 4 | // 5 | // Created by San Zhang on 9/6/16. 6 | // Copyright © 2016 UMeng. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UMConfigure : NSObject 12 | 13 | /** 初始化友盟所有组件产品 14 | @param appKey 开发者在友盟官网申请的appkey. 15 | @param channel 渠道标识,可设置nil表示"App Store". 16 | */ 17 | + (void)initWithAppkey:(NSString *)appKey channel:(NSString *)channel; 18 | 19 | /** 设置是否在console输出sdk的log信息. 20 | @param bFlag 默认NO(不输出log); 设置为YES, 输出可供调试参考的log信息. 发布产品时必须设置为NO. 21 | */ 22 | + (void)setLogEnabled:(BOOL)bFlag; 23 | 24 | /** 设置是否对日志信息进行加密, 默认NO(不加密). 25 | @param value 设置为YES, umeng SDK 会将日志信息做加密处理 26 | */ 27 | + (void)setEncryptEnabled:(BOOL)value; 28 | 29 | + (NSString *)umidString; 30 | 31 | /** 32 | 集成测试需要device_id 33 | */ 34 | + (NSString*)deviceIDForIntegration; 35 | 36 | 37 | 38 | @end 39 | -------------------------------------------------------------------------------- /ios/RNUMCommon/UMPush/UMPush: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yolinsoft/react-native-dk-umeng/d7fda29c2ba35bc40f06e6ae3702245ed784d175/ios/RNUMCommon/UMPush/UMPush -------------------------------------------------------------------------------- /ios/RNUMCommon/UMPush/UMessage.h: -------------------------------------------------------------------------------- 1 | // 2 | // UMessage.h 3 | // UMessage 4 | // 5 | // Created by shile on 2017/4/1. 6 | // Copyright © 2017年 umeng.com. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import 12 | /** String type for alias 13 | */ 14 | //新浪微博 15 | UIKIT_EXTERN NSString * __nonnull const kUMessageAliasTypeSina; 16 | //腾讯微博 17 | UIKIT_EXTERN NSString * __nonnull const kUMessageAliasTypeTencent; 18 | //QQ 19 | UIKIT_EXTERN NSString * __nonnull const kUMessageAliasTypeQQ; 20 | //微信 21 | UIKIT_EXTERN NSString * __nonnull const kUMessageAliasTypeWeiXin; 22 | //百度 23 | UIKIT_EXTERN NSString * __nonnull const kUMessageAliasTypeBaidu; 24 | //人人网 25 | UIKIT_EXTERN NSString * __nonnull const kUMessageAliasTypeRenRen; 26 | //开心网 27 | UIKIT_EXTERN NSString * __nonnull const kUMessageAliasTypeKaixin; 28 | //豆瓣 29 | UIKIT_EXTERN NSString * __nonnull const kUMessageAliasTypeDouban; 30 | //facebook 31 | UIKIT_EXTERN NSString * __nonnull const kUMessageAliasTypeFacebook; 32 | //twitter 33 | UIKIT_EXTERN NSString * __nonnull const kUMessageAliasTypeTwitter; 34 | 35 | 36 | //error for handle 37 | extern NSString * __nonnull const kUMessageErrorDomain; 38 | 39 | typedef NS_ENUM(NSInteger, kUMessageError) { 40 | /**未知错误*/ 41 | kUMessageErrorUnknown = 0, 42 | /**响应出错*/ 43 | kUMessageErrorResponseErr = 1, 44 | /**操作失败*/ 45 | kUMessageErrorOperateErr = 2, 46 | /**参数非法*/ 47 | kUMessageErrorParamErr = 3, 48 | /**条件不足(如:还未获取device_token,添加tag是不成功的)*/ 49 | kUMessageErrorDependsErr = 4, 50 | /**服务器限定操作*/ 51 | kUMessageErrorServerSetErr = 5, 52 | }; 53 | 54 | typedef NS_OPTIONS(NSUInteger, UMessageAuthorizationOptions) { 55 | UMessageAuthorizationOptionNone = 0, 56 | UMessageAuthorizationOptionBadge = (1 << 0), 57 | UMessageAuthorizationOptionSound = (1 << 1), 58 | UMessageAuthorizationOptionAlert = (1 << 2), 59 | }; 60 | 61 | typedef void (^UMPlaunchFinishBlock)(); 62 | 63 | @interface UMessageRegisterEntity : NSObject 64 | //需要注册的类型 65 | @property (nonatomic, assign) NSInteger types; 66 | 67 | @property (nonatomic, strong) NSSet * __nullable categories; 68 | @end 69 | 70 | /** UMessage:开发者使用主类(API) 71 | */ 72 | @interface UMessage : NSObject 73 | 74 | 75 | ///--------------------------------------------------------------------------------------- 76 | /// @name settings(most required) 77 | ///--------------------------------------------------------------------------------------- 78 | 79 | //--required 80 | 81 | /** 82 | 友盟推送的注册接口 83 | 84 | @param launchOptions 系统的launchOptions启动消息参数用于处理用户通过消息打开应用相关信息。 85 | @param entity 友盟推送的注册类如果使用默认的注册,Entity设置为nil即可。如需其他的可选择其他参数,具体的参考demo或者文档。 86 | @param completionHandler iOS10授权后的回调。 87 | */ 88 | + (void)registerForRemoteNotificationsWithLaunchOptions:(NSDictionary * __nullable)launchOptions Entity:(UMessageRegisterEntity * __nullable)entity completionHandler:(void (^ __nullable)(BOOL granted, NSError *_Nullable error))completionHandler; 89 | 90 | 91 | /** 解除RemoteNotification的注册(关闭消息推送,实际调用:[[UIApplication sharedApplication] unregisterForRemoteNotifications]) 92 | 93 | iOS10.0,iOS10.1两个版本存在系统bug,调用此方法后可能会导致无法再次打开推送 94 | */ 95 | + (void)unregisterForRemoteNotifications; 96 | 97 | /** 向友盟注册该设备的deviceToken,便于发送Push消息 98 | @param deviceToken APNs返回的deviceToken 99 | */ 100 | + (void)registerDeviceToken:( NSData * __nullable)deviceToken; 101 | 102 | /** 应用处于运行时(前台、后台)的消息处理,回传点击数据 103 | @param userInfo 消息参数 104 | */ 105 | + (void)didReceiveRemoteNotification:( NSDictionary * __nullable)userInfo; 106 | 107 | /** 设置是否允许SDK自动清空角标(默认开启) 108 | @param value 是否开启角标清空 109 | */ 110 | + (void)setBadgeClear:(BOOL)value; 111 | 112 | /** 设置是否允许SDK当应用在前台运行收到Push时弹出Alert框(默认开启) 113 | @param value 是否开启弹出框 114 | */ 115 | + (void)setAutoAlert:(BOOL)value; 116 | 117 | /** 为某个消息发送点击事件 118 | */ 119 | + (void)sendClickReportForRemoteNotification:(NSDictionary * __nullable)userInfo; 120 | 121 | 122 | ///--------------------------------------------------------------------------------------- 123 | /// @name tag (optional) 124 | ///--------------------------------------------------------------------------------------- 125 | 126 | 127 | /** 获取当前绑定设备上的所有tag(每台设备最多绑定1024个tag) 128 | @warning 获取列表的先决条件是已经成功获取到device_token,否则失败(kUMessageErrorDependsErr) 129 | @param handle responseTags为绑定的tag 130 | 集合,remain剩余可用的tag数,为-1时表示异常,error为获取失败时的信息(ErrCode:kUMessageError) 131 | */ 132 | + (void)getTags:(void (^__nonnull)(NSSet * __nonnull responseTags,NSInteger remain,NSError * __nullable error))handle; 133 | 134 | /** 绑定一个或多个tag至设备,每台设备最多绑定1024个tag,超过1024个,绑定tag不再成功,可`removeTag`来精简空间 135 | @warning 添加tag的先决条件是已经成功获取到device_token,否则直接添加失败(kUMessageErrorDependsErr) 136 | @param tag tag标记,可以为单个tag(NSString)也可以为tag集合(NSArray、NSSet),单个tag最大允许长度128字节,编码UTF-8,超过长度绑定失败 137 | @param handle responseTags为绑定的tag集合,remain剩余可用的tag数,为-1时表示异常,error为获取失败时的信息(ErrCode:kUMessageError) 138 | */ 139 | + (void)addTags:(__nonnull id)tag response:( void (^ __nonnull)(id __nullable responseObject ,NSInteger remain,NSError * __nullable error))handle; 140 | 141 | /** 删除设备中绑定的一个或多个tag 142 | @warning 添加tag的先决条件是已经成功获取到device_token,否则失败(kUMessageErrorDependsErr) 143 | @param tag tag标记,可以为单个tag(NSString)也可以为tag集合(NSArray、NSSet),单个tag最大允许长度128字节,编码UTF-8,超过长度删除失败 144 | @param handle responseTags为绑定的tag集合,remain剩余可用的tag数,为-1时表示异常,error为获取失败时的信息(ErrCode:kUMessageError) 145 | */ 146 | + (void)deleteTags:(__nonnull id)tag response:(void (^__nonnull)(id __nullable responseObject,NSInteger remain,NSError * __nullable error))handle; 147 | 148 | 149 | ///--------------------------------------------------------------------------------------- 150 | /// @name WeightedTag (optional) 151 | ///--------------------------------------------------------------------------------------- 152 | 153 | /** 154 | 绑定一个或多个weightedtag以及权值至设备 155 | 156 | @warning 添加tag的先决条件是已经成功获取到device_token,否则直接添加失败(kUMessageErrorDependsErr) 157 | @param weightedTag tag标记,为NSDictionary类型,key为weightedtag名称,value为权值。 158 | @param handle responseTags为绑定的tag集合,remain剩余可用的tag数,为-1时表示异常,error为获取失败时的信息(ErrCode:kUMessageError) 159 | */ 160 | + (void)addWeightedTags:(NSDictionary * __nonnull)weightedTag response:(void (^__nonnull)(id __nullable responseObject ,NSInteger remain,NSError * __nullable error))handle; 161 | 162 | /** 获取当前绑定设备上的所有Weightedtag 163 | @warning 获取列表的先决条件是已经成功获取到device_token,否则失败(kUMessageErrorDependsErr) 164 | @param handle responseWeightedTags为绑定的WeightedTags字典,key为weightedtag名称,value为权值,remain剩余可用的weightedtag数,为-1时表示异常,error为获取失败时的信息(ErrCode:kUMessageError) 165 | */ 166 | + (void)getWeightedTags:(void (^__nonnull)(NSDictionary * __nullable responseWeightedTags,NSInteger remain,NSError * __nullable error))handle; 167 | 168 | /** 169 | 删除一个设备中绑定的一个或多个weightedtag 170 | 171 | @warning 添加tag的先决条件是已经成功获取到device_token,否则直接添加失败(kUMessageErrorDependsErr) 172 | @param weightedTags tag标记,为NSDictionary类型,key为tag名称,value为权值。 173 | @param handle responseTags为绑定的tag集合,remain剩余可用的tag数,为-1时表示异常,error为获取失败时的信息(ErrCode:kUMessageError) 174 | */ 175 | + (void)deleteWeightedTags:(id __nonnull)weightedTags response:(void (^__nonnull)(id __nullable responseObject,NSInteger remain,NSError * __nullable error))handle; 176 | 177 | /// @name alias (optional) 178 | ///--------------------------------------------------------------------------------------- 179 | 180 | 181 | /** 绑定一个别名至设备(含账户,和平台类型) 182 | @warning 添加Alias的先决条件是已经成功获取到device_token,否则失败(kUMessageErrorDependsErr) 183 | @param name 账户,例如email 184 | @param type 平台类型,参见本文件头部的`kUMessageAliasType...`,例如:kUMessageAliasTypeSina 185 | @param handle block返回数据,error为获取失败时的信息,responseObject为成功返回的数据 186 | */ 187 | + (void)addAlias:(NSString * __nonnull)name type:(NSString * __nonnull)type response:(void (^__nonnull)(id __nullable responseObject,NSError * __nullable error))handle; 188 | 189 | /** 绑定一个别名至设备(含账户,和平台类型),并解绑这个别名曾今绑定过的设备。 190 | @warning 添加Alias的先决条件是已经成功获取到device_token,否则失败(kUMessageErrorDependsErr) 191 | @param name 账户,例如email 192 | @param type 平台类型,参见本文件头部的`kUMessageAliasType...`,例如:kUMessageAliasTypeSina 193 | @param handle block返回数据,error为获取失败时的信息,responseObject为成功返回的数据 194 | */ 195 | + (void)setAlias:(NSString * __nonnull )name type:(NSString * __nonnull)type response:(void (^__nonnull)(id __nullable responseObject,NSError * __nullable error))handle; 196 | 197 | /** 删除一个设备的别名绑定 198 | @warning 删除Alias的先决条件是已经成功获取到device_token,否则失败(kUMessageErrorDependsErr) 199 | @param name 账户,例如email 200 | @param type 平台类型,参见本文件头部的`kUMessageAliasType...`,例如:kUMessageAliasTypeSina 201 | @param handle block返回数据,error为获取失败时的信息,responseObject为成功返回的数据 202 | */ 203 | + (void)removeAlias:(NSString * __nonnull)name type:(NSString * __nonnull)type response:(void (^__nonnull)(id __nullable responseObject, NSError * __nullable error))handle; 204 | 205 | 206 | /** 添加一个启动页的开屏消息 207 | */ 208 | +(void)addLaunchMessage; 209 | 210 | /** 添加一个插屏消息 211 | @warning 需先在触发一次才可以在后台配置中找到该标识 212 | @param label 当前位置的标识 213 | */ 214 | +(void)addCardMessageWithLabel:(NSString* __nonnull)label; 215 | 216 | /** 217 | @warning 需先在触发一次才可以在后台配置中找到该标识 218 | 添加一个自定义插屏消息 219 | 220 | @param portraitsize portrait时显示的size 221 | @param landscapesize landscape时显示的大小 222 | @param button button 可以自定义的button 223 | @param label 标识 224 | */ 225 | +(void)addCustomCardMessageWithPortraitSize:(CGSize )portraitsize LandscapeSize:(CGSize )landscapesize CloseBtn:(UIButton * __nullable )button Label:(NSString * __nonnull)label umCustomCloseButtonDisplayMode:(BOOL )displaymode; 226 | 227 | 228 | /** 229 | @warning 需先在触发一次才可以在后台配置中找到该标识 230 | 增加一个文本插屏消息 231 | 232 | @param label 当前位置的标识 233 | */ 234 | +(void)addPlainTextCardMessageWithTitleFont:(UIFont * __nullable)titlefont ContentFont:(UIFont * __nullable)contentfont buttonFont:(UIFont * __nullable)buttonfont Label:(NSString * __nonnull)label;; 235 | 236 | /** 237 | 设置应用内通知的模式 238 | 239 | @param debugmode 是否是debug模式 240 | */ 241 | +(void)openDebugMode:(BOOL)debugmode; 242 | 243 | /** 244 | @warning 注意此方法使用场景必须有Navigation 245 | 设置webViewController在.h文件中声明一个叫url的参数,SDK内部会去调用 246 | @param webViewController webViewController 247 | */ 248 | +(void)setWebViewController:(UIViewController * __nonnull)webViewController; 249 | @end 250 | -------------------------------------------------------------------------------- /ios/RNUMCommon/UMPushModule.h: -------------------------------------------------------------------------------- 1 | // 2 | // PushModule.h 3 | // UMComponent 4 | // 5 | // Created by wyq.Cloudayc on 11/09/2017. 6 | // Copyright © 2017 Facebook. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import 12 | 13 | @interface UMPushModule : NSObject 14 | //+(instancetype)shareInstance; 15 | +(void)registerWithAppkey:(NSString *)appkey launchOptions:(NSDictionary *)launchOptions; 16 | +(void)registerDeviceToken:(NSData *)deviceToken; 17 | +(void)didReceiveRemoteNotification:(NSDictionary *)userInfo; 18 | +(void)setAutoAlert:(BOOL)autoAlert; 19 | @end 20 | -------------------------------------------------------------------------------- /ios/RNUMCommon/UMPushModule.m: -------------------------------------------------------------------------------- 1 | // 2 | // PushModule.m 3 | // UMComponent 4 | // 5 | // Created by wyq.Cloudayc on 11/09/2017. 6 | // Copyright © 2017 Facebook. All rights reserved. 7 | // 8 | 9 | #import "UMPushModule.h" 10 | #import 11 | #import 12 | #import 13 | static NSString * const deviceTokenStr = @"deviceToken"; 14 | @interface UMPushModule() 15 | //@property (nonatomic, copy) NSString *token; 16 | @end 17 | @implementation UMPushModule 18 | { 19 | bool _hasListeners; 20 | } 21 | RCT_EXPORT_MODULE(); 22 | 23 | //+(instancetype)shareInstance{ 24 | // static dispatch_once_t onceToken; 25 | // static UMPushModule *sharedInstance = nil; 26 | // dispatch_once(&onceToken, ^{ 27 | // sharedInstance = [[self alloc]init]; 28 | // }); 29 | // return sharedInstance; 30 | //} 31 | 32 | // /**未知错误*/ 33 | // kUMessageErrorUnknown = 0, 34 | // /**响应出错*/ 35 | // kUMessageErrorResponseErr = 1, 36 | // /**操作失败*/ 37 | // kUMessageErrorOperateErr = 2, 38 | // /**参数非法*/ 39 | // kUMessageErrorParamErr = 3, 40 | // /**条件不足(如:还未获取device_token,添加tag是不成功的)*/ 41 | // kUMessageErrorDependsErr = 4, 42 | // /**服务器限定操作*/ 43 | // kUMessageErrorServerSetErr = 5, 44 | - (NSString *)checkErrorMessage:(NSInteger)code 45 | { 46 | switch (code) { 47 | case 1: 48 | return @"响应出错"; 49 | break; 50 | case 2: 51 | return @"操作失败"; 52 | break; 53 | case 3: 54 | return @"参数非法"; 55 | break; 56 | case 4: 57 | return @"条件不足(如:还未获取device_token,添加tag是不成功的)"; 58 | break; 59 | case 5: 60 | return @"服务器限定操作"; 61 | break; 62 | default: 63 | break; 64 | } 65 | return nil; 66 | } 67 | 68 | - (void)handleResponse:(id _Nonnull)responseObject remain:(NSInteger)remain error:(NSError * _Nonnull)error resolver:(RCTPromiseResolveBlock)resolve 69 | rejecter:(RCTPromiseRejectBlock)reject 70 | { 71 | if (resolve) { 72 | if (error) { 73 | NSString *msg = [self checkErrorMessage:error.code]; 74 | if (msg.length == 0) { 75 | msg = error.localizedDescription; 76 | } 77 | reject(@(error.code).stringValue,msg,nil); 78 | } else { 79 | if ([responseObject isKindOfClass:[NSDictionary class]]) { 80 | NSDictionary *retDict = responseObject; 81 | if ([retDict[@"success"] isEqualToString:@"ok"]) { 82 | resolve(@(0)); 83 | } else { 84 | reject(@"1",@(remain).stringValue,nil); 85 | } 86 | } else { 87 | reject(@"1",@(remain).stringValue,nil); 88 | } 89 | 90 | } 91 | } 92 | } 93 | 94 | - (void)handleGetTagResponse:(NSSet * _Nonnull)responseTags remain:(NSInteger)remain error:(NSError * _Nonnull)error resolver:(RCTPromiseResolveBlock)resolve 95 | rejecter:(RCTPromiseRejectBlock)reject 96 | { 97 | if (resolve) { 98 | if (error) { 99 | NSString *msg = [self checkErrorMessage:error.code]; 100 | if (msg.length == 0) { 101 | msg = error.localizedDescription; 102 | } 103 | // completion(@[@(error.code), @(remain), @[]]); 104 | reject(@(error.code).stringValue,msg,nil); 105 | } else { 106 | if ([responseTags isKindOfClass:[NSSet class]]) { 107 | NSArray *retList = responseTags.allObjects; 108 | resolve(@(0)); 109 | } else { 110 | reject(@"1",@(remain).stringValue,nil); 111 | } 112 | } 113 | } 114 | } 115 | - (void)handleAliasResponse:(id _Nonnull)responseObject error:(NSError * _Nonnull)error resolver:(RCTPromiseResolveBlock)resolve 116 | rejecter:(RCTPromiseRejectBlock)reject 117 | { 118 | if (resolve) { 119 | if (error) { 120 | NSString *msg = [self checkErrorMessage:error.code]; 121 | if (msg.length == 0) { 122 | msg = error.localizedDescription; 123 | } 124 | reject(@(error.code).stringValue,msg,nil); 125 | } else { 126 | if ([responseObject isKindOfClass:[NSDictionary class]]) { 127 | NSDictionary *retDict = responseObject; 128 | if ([retDict[@"success"] isEqualToString:@"ok"]) { 129 | resolve(@(0)); 130 | } else { 131 | reject(@"1",@"",nil); 132 | } 133 | } else { 134 | reject(@"1",@"",nil); 135 | } 136 | 137 | } 138 | } 139 | } 140 | 141 | +(void)registerWithAppkey:(NSString *)appkey launchOptions:(NSDictionary *)launchOptions{ 142 | // UMessage 143 | // Push's basic setting 144 | UMessageRegisterEntity * entity = [[UMessageRegisterEntity alloc] init]; 145 | //type是对推送的几个参数的选择,可以选择一个或者多个。默认是三个全部打开,即:声音,弹窗,角标 146 | entity.types = UMessageAuthorizationOptionBadge|UMessageAuthorizationOptionAlert | UMessageAuthorizationOptionSound; 147 | [UMessage registerForRemoteNotificationsWithLaunchOptions:launchOptions Entity:entity completionHandler:^(BOOL granted, NSError * _Nullable error) { 148 | if (granted) { 149 | 150 | } else { 151 | 152 | } 153 | }]; 154 | } 155 | 156 | +(void)registerDeviceToken:(NSData *)deviceToken{ 157 | 158 | NSString *token = [[[[deviceToken description] stringByReplacingOccurrencesOfString: @"<" withString: @""] 159 | stringByReplacingOccurrencesOfString: @">" withString: @""] 160 | stringByReplacingOccurrencesOfString: @" " withString: @""]; 161 | if (token.length > 0) { 162 | [[NSUserDefaults standardUserDefaults]setObject:token forKey:deviceTokenStr]; 163 | } 164 | [UMessage registerDeviceToken:deviceToken]; 165 | } 166 | 167 | +(void)didReceiveRemoteNotification:(NSDictionary *)userInfo{ 168 | [UMessage didReceiveRemoteNotification:userInfo]; 169 | } 170 | 171 | +(void)setAutoAlert:(BOOL)autoAlert{ 172 | [UMessage setAutoAlert:autoAlert]; 173 | } 174 | 175 | 176 | RCT_EXPORT_METHOD(getDeviceToken:(RCTPromiseResolveBlock)resolve 177 | rejecter:(RCTPromiseRejectBlock)reject){ 178 | NSString *token = [[NSUserDefaults standardUserDefaults]objectForKey:deviceTokenStr]; 179 | 180 | if (token.length > 0) { 181 | resolve([token copy]); 182 | } else { 183 | reject(@"1",@"无token",nil); 184 | } 185 | } 186 | 187 | RCT_EXPORT_METHOD(addTag:(NSString *)tag resolver:(RCTPromiseResolveBlock)resolve 188 | rejecter:(RCTPromiseRejectBlock)reject) 189 | { 190 | [UMessage addTags:tag response:^(id _Nonnull responseObject, NSInteger remain, NSError * _Nonnull error) { 191 | [self handleResponse:responseObject remain:remain error:error resolver:(RCTPromiseResolveBlock)resolve 192 | rejecter:(RCTPromiseRejectBlock)reject]; 193 | }]; 194 | } 195 | 196 | RCT_EXPORT_METHOD(deleteTag:(NSString *)tag resolver:(RCTPromiseResolveBlock)resolve 197 | rejecter:(RCTPromiseRejectBlock)reject) 198 | { 199 | [UMessage deleteTags:tag response:^(id _Nonnull responseObject, NSInteger remain, NSError * _Nonnull error) { 200 | [self handleResponse:responseObject remain:remain error:error resolver:(RCTPromiseResolveBlock)resolve 201 | rejecter:(RCTPromiseRejectBlock)reject]; 202 | }]; 203 | } 204 | 205 | RCT_EXPORT_METHOD(listTagResolver:(RCTPromiseResolveBlock)resolve 206 | rejecter:(RCTPromiseRejectBlock)reject) 207 | { 208 | [UMessage getTags:^(NSSet * _Nonnull responseTags, NSInteger remain, NSError * _Nonnull error) { 209 | [self handleGetTagResponse:responseTags remain:remain error:error resolver:(RCTPromiseResolveBlock)resolve 210 | rejecter:(RCTPromiseRejectBlock)reject]; 211 | }]; 212 | } 213 | 214 | RCT_EXPORT_METHOD(addAlias:(NSString *)name type:(NSString *)type resolver:(RCTPromiseResolveBlock)resolve 215 | rejecter:(RCTPromiseRejectBlock)reject) 216 | { 217 | [UMessage addAlias:name type:type response:^(id _Nonnull responseObject, NSError * _Nonnull error) { 218 | [self handleAliasResponse:responseObject error:error resolver:resolve rejecter:reject]; 219 | }]; 220 | } 221 | 222 | RCT_EXPORT_METHOD(addExclusiveAlias:(NSString *)name type:(NSString *)type resolver:(RCTPromiseResolveBlock)resolve 223 | rejecter:(RCTPromiseRejectBlock)reject) 224 | { 225 | [UMessage setAlias:name type:type response:^(id _Nonnull responseObject, NSError * _Nonnull error) { 226 | [self handleAliasResponse:responseObject error:error resolver:(RCTPromiseResolveBlock)resolve 227 | rejecter:(RCTPromiseRejectBlock)reject]; 228 | }]; 229 | } 230 | 231 | RCT_EXPORT_METHOD(deleteAlias:(NSString *)name type:(NSString *)type resolver:(RCTPromiseResolveBlock)resolve 232 | rejecter:(RCTPromiseRejectBlock)reject) 233 | { 234 | [UMessage removeAlias:name type:type response:^(id _Nonnull responseObject, NSError * _Nonnull error) { 235 | [self handleAliasResponse:responseObject error:error resolver:(RCTPromiseResolveBlock)resolve 236 | rejecter:(RCTPromiseRejectBlock)reject]; 237 | }]; 238 | } 239 | @end 240 | -------------------------------------------------------------------------------- /ios/RNUMCommon/UMShare/SocialLibraries/QQ/UMSocialQQHandler.h: -------------------------------------------------------------------------------- 1 | // 2 | // UMSQQDataTypeTableViewController.h 3 | // SocialSDK 4 | // 5 | // Created by umeng on 16/4/15. 6 | // Copyright © 2016年 dongjianxiong. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UMSocialQQHandler : UMSocialHandler 12 | 13 | + (UMSocialQQHandler *)defaultManager; 14 | 15 | /** QQ是否支持网页分享 16 | * @param support 是否支持 17 | */ 18 | - (void)setSupportWebView:(BOOL)support __deprecated; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /ios/RNUMCommon/UMShare/SocialLibraries/QQ/libSocialQQ.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yolinsoft/react-native-dk-umeng/d7fda29c2ba35bc40f06e6ae3702245ed784d175/ios/RNUMCommon/UMShare/SocialLibraries/QQ/libSocialQQ.a -------------------------------------------------------------------------------- /ios/RNUMCommon/UMShare/SocialLibraries/Sina/UMSocialSinaHandler.h: -------------------------------------------------------------------------------- 1 | // 2 | // UMSocialSinaHandler.h 3 | // UMSocialSDK 4 | // 5 | // Created by wyq.Cloudayc on 2/21/17. 6 | // Copyright © 2017 UMeng. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface UMSocialSinaHandler : UMSocialHandler 13 | 14 | + (UMSocialSinaHandler *)defaultManager; 15 | 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /ios/RNUMCommon/UMShare/SocialLibraries/Sina/libSocialSina.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yolinsoft/react-native-dk-umeng/d7fda29c2ba35bc40f06e6ae3702245ed784d175/ios/RNUMCommon/UMShare/SocialLibraries/Sina/libSocialSina.a -------------------------------------------------------------------------------- /ios/RNUMCommon/UMShare/SocialLibraries/WeChat/UMSocialWechatHandler.h: -------------------------------------------------------------------------------- 1 | // 2 | // UMSWechatDataTypeTableViewController.h 3 | // SocialSDK 4 | // 5 | // Created by umeng on 16/4/14. 6 | // Copyright © 2016年 dongjianxiong. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface UMSocialWechatHandler : UMSocialHandler 13 | 14 | + (instancetype)defaultManager; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /ios/RNUMCommon/UMShare/SocialLibraries/WeChat/libSocialWeChat.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yolinsoft/react-native-dk-umeng/d7fda29c2ba35bc40f06e6ae3702245ed784d175/ios/RNUMCommon/UMShare/SocialLibraries/WeChat/libSocialWeChat.a -------------------------------------------------------------------------------- /ios/RNUMCommon/UMShare/UMCommonLogMacros.h: -------------------------------------------------------------------------------- 1 | // 2 | // UMCommonLogMacros.h 3 | // testUMCommonLog 4 | // 5 | // Created by 张军华 on 2017/11/29. 6 | // Copyright © 2017年 张军华. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #define USing_CommonLog_Reflection 12 | 13 | #ifndef USing_CommonLog_Reflection 14 | 15 | #import "UMCommonLogConfig.h" 16 | 17 | /** 18 | * 根据等级打印日志 19 | * @param component 打印对应的组件 @see UMCommonComponent 20 | * @param logFlag 控制打印分级的枚举变量 @see UMCommonLogFlag 21 | * @param file 打印日志的文件 22 | * @param function 打印日志的函数 23 | * @param line 打印的日志的行数 24 | * @param format 需要打印的日志格式内容 25 | * @param ... 可变参数 26 | * @dicuss 本库不需要直接调用,可以用简易函数宏 @see UMCommonLogError,UMCommonLogWarn,UMCommonLogInfo,UMCommonLogDebug 27 | */ 28 | FOUNDATION_EXPORT void UMCommonLog(UMCommonComponent component,UMCommonLogFlag logFlag,const char* file,const char* function,NSUInteger line,NSString *format, ...) NS_FORMAT_FUNCTION(6,7); 29 | 30 | 31 | //UMCommon的日志宏 32 | //简易函数类似于系统的NSLog函数,线程安全 33 | #define UMCommonLogError(format, ...) UMCommonLog(UMCommonComponent_UMCommon,UMCommonLogFlagError,__FILE__,__PRETTY_FUNCTION__,__LINE__,format,##__VA_ARGS__) 34 | #define UMCommonLogWarn(format, ...) UMCommonLog(UMCommonComponent_UMCommon,UMCommonLogFlagWarning,__FILE__,__PRETTY_FUNCTION__,__LINE__,format,##__VA_ARGS__) 35 | #define UMCommonLogInfo(format, ...) UMCommonLog(UMCommonComponent_UMCommon,UMCommonLogFlagInfo,__FILE__,__PRETTY_FUNCTION__,__LINE__,format,##__VA_ARGS__) 36 | #define UMCommonLogDebug(format, ...) UMCommonLog(UMCommonComponent_UMCommon,UMCommonLogFlagDebug,__FILE__,__PRETTY_FUNCTION__,__LINE__,format,##__VA_ARGS__) 37 | #define UMCommonLogVerbose(format, ...) UMCommonLog(UMCommonComponent_UMCommon,UMCommonLogFlagVerbose,__FILE__,__PRETTY_FUNCTION__,__LINE__,format,##__VA_ARGS__) 38 | 39 | 40 | //UMAnalytics的日志宏 41 | //简易函数类似于系统的NSLog函数,线程安全 42 | #define UMAnalyticsLogError(format, ...) UMCommonLog(UMCommonComponent_UMAnalytics,UMCommonLogFlagError,__FILE__,__PRETTY_FUNCTION__,__LINE__,format,##__VA_ARGS__) 43 | #define UMAnalyticsLogWarn(format, ...) UMCommonLog(UMCommonComponent_UMAnalytics,UMCommonLogFlagWarning,__FILE__,__PRETTY_FUNCTION__,__LINE__,format,##__VA_ARGS__) 44 | #define UMAnalyticsLogInfo(format, ...) UMCommonLog(UMCommonComponent_UMAnalytics,UMCommonLogFlagInfo,__FILE__,__PRETTY_FUNCTION__,__LINE__,format,##__VA_ARGS__) 45 | #define UMAnalyticsLogDebug(format, ...) UMCommonLog(UMCommonComponent_UMAnalytics,UMCommonLogFlagDebug,__FILE__,__PRETTY_FUNCTION__,__LINE__,format,##__VA_ARGS__) 46 | #define UMAnalyticsLogVerbose(format, ...) UMCommonLog(UMCommonComponent_UMAnalytics,UMCommonLogFlagVerbose,__FILE__,__PRETTY_FUNCTION__,__LINE__,format,##__VA_ARGS__) 47 | 48 | //UMPush 的日志宏 49 | //简易函数类似于系统的NSLog函数,线程安全 50 | #define UMPushLogError(format, ...) UMCommonLog(UMCommonComponent_UMPush,UMCommonLogFlagError,__FILE__,__PRETTY_FUNCTION__,__LINE__,format,##__VA_ARGS__) 51 | #define UMPushLogWarn(format, ...) UMCommonLog(UMCommonComponent_UMPush,UMCommonLogFlagWarning,__FILE__,__PRETTY_FUNCTION__,__LINE__,format,##__VA_ARGS__) 52 | #define UMPushLogInfo(format, ...) UMCommonLog(UMCommonComponent_UMPush,UMCommonLogFlagInfo,__FILE__,__PRETTY_FUNCTION__,__LINE__,format,##__VA_ARGS__) 53 | #define UMPushLogDebug(format, ...) UMCommonLog(UMCommonComponent_UMPush,UMCommonLogFlagDebug,__FILE__,__PRETTY_FUNCTION__,__LINE__,format,##__VA_ARGS__) 54 | #define UMPushLogVerbose(format, ...) UMCommonLog(UMCommonComponent_UMPush,UMCommonLogFlagVerbose,__FILE__,__PRETTY_FUNCTION__,__LINE__,format,##__VA_ARGS__) 55 | 56 | //UMShare 的日志宏 57 | //简易函数类似于系统的NSLog函数,线程安全 58 | #define UMShareLogError(format, ...) UMCommonLog(UMCommonComponent_UMShare,UMCommonLogFlagError,__FILE__,__PRETTY_FUNCTION__,__LINE__,format,##__VA_ARGS__) 59 | #define UMShareLogWarn(format, ...) UMCommonLog(UMCommonComponent_UMShare,UMCommonLogFlagWarning,__FILE__,__PRETTY_FUNCTION__,__LINE__,format,##__VA_ARGS__) 60 | #define UMShareLogInfo(format, ...) UMCommonLog(UMCommonComponent_UMShare,UMCommonLogFlagInfo,__FILE__,__PRETTY_FUNCTION__,__LINE__,format,##__VA_ARGS__) 61 | #define UMShareLogDebug(format, ...) UMCommonLog(UMCommonComponent_UMShare,UMCommonLogFlagDebug,__FILE__,__PRETTY_FUNCTION__,__LINE__,format,##__VA_ARGS__) 62 | #define UMShareLogVerbose(format, ...) UMCommonLog(UMCommonComponent_UMShare,UMCommonLogFlagVerbose,__FILE__,__PRETTY_FUNCTION__,__LINE__,format,##__VA_ARGS__) 63 | 64 | #else 65 | 66 | #define UMCommonLog UMCommonLog##UMShareSuffix 67 | #define UMCommonPrefixSubNameLog UMCommonPrefixSubNameLog##UMShareSuffix 68 | #define registerUMComponent registerUMComponent##UMShareSuffix 69 | #define setUMCommonComponentLevel setUMCommonComponentLevel##UMShareSuffix 70 | #define getUMCommonLogManager getUMCommonLogManager##UMShareSuffix 71 | #define getMetaUMCommonLogManager getMetaUMCommonLogManager##UMShareSuffix 72 | #define checkUMCommonLogManager checkUMCommonLogManager##UMShareSuffix 73 | #define checkValidUMCommonLogLevel checkValidUMCommonLogLevel##UMShareSuffix 74 | #define doUMCommonLog doUMCommonLog##UMShareSuffix 75 | #define doUMCommonPrefixSubNameLog doUMCommonPrefixSubNameLog##UMShareSuffix 76 | 77 | FOUNDATION_EXPORT BOOL registerUMComponent(NSInteger component,NSString* prefixName,NSString* componentVersion); 78 | FOUNDATION_EXPORT BOOL setUMCommonComponentLevel(NSInteger component,NSUInteger componentLevel); 79 | FOUNDATION_EXPORT void UMCommonLog(NSInteger component,NSInteger logFlag,const char* file,const char* function,NSUInteger line,NSString *format, ...) NS_FORMAT_FUNCTION(6,7); 80 | FOUNDATION_EXPORT void UMCommonPrefixSubNameLog(NSInteger component,NSInteger logFlag,const char* prefixSubName,const char* file,const char* function,NSUInteger line,NSString *format, ...) NS_FORMAT_FUNCTION(7,8); 81 | 82 | //获得UMCommonLog.bundle的国际化的字符串宏和对应的函数 83 | #define UMCommonLogTableNameForUMCommonUMShareSuffix @"UMSocialPromptLocalizable" 84 | #define UMCommonLogBundleNameForUMCommonUMShareSuffix @"UMCommonLog" 85 | #define UMCommonLogBundle UMCommonLogBundle##UMShareSuffix 86 | FOUNDATION_EXPORT NSBundle* UMCommonLogBundle(); 87 | #define UMLocalizedStringForUMCommonSuffix(key) NSLocalizedStringWithDefaultValue(key,UMCommonLogTableNameForUMCommonUMShareSuffix,UMCommonLogBundle(), @"", nil) 88 | 89 | 90 | //UMCommon的日志宏 91 | //简易函数类似于系统的NSLog函数,线程安全 92 | #define UMCommonLogError(format, ...) UMCommonLog(1,1,__FILE__,__PRETTY_FUNCTION__,__LINE__,format,##__VA_ARGS__) 93 | #define UMCommonLogWarn(format, ...) UMCommonLog(1,2,__FILE__,__PRETTY_FUNCTION__,__LINE__,format,##__VA_ARGS__) 94 | #define UMCommonLogInfo(format, ...) UMCommonLog(1,4,__FILE__,__PRETTY_FUNCTION__,__LINE__,format,##__VA_ARGS__) 95 | #define UMCommonLogDebug(format, ...) UMCommonLog(1,8,__FILE__,__PRETTY_FUNCTION__,__LINE__,format,##__VA_ARGS__) 96 | #define UMCommonLogVerbose(format, ...) UMCommonLog(1,16,__FILE__,__PRETTY_FUNCTION__,__LINE__,format,##__VA_ARGS__) 97 | 98 | //UMCommon的分级日志宏 99 | #define UMCommonPrefixSubName ".Network" 100 | #define UMCommonPrefixSubNameLogError(format, ...) UMCommonPrefixSubNameLog(1,1,UMCommonPrefixSubName,__FILE__,__PRETTY_FUNCTION__,__LINE__,format,##__VA_ARGS__) 101 | #define UMCommonPrefixSubNameLogWarn(format, ...) UMCommonPrefixSubNameLog(1,2,UMCommonPrefixSubName,__FILE__,__PRETTY_FUNCTION__,__LINE__,format,##__VA_ARGS__) 102 | #define UMCommonPrefixSubNameLogInfo(format, ...) UMCommonPrefixSubNameLog(1,4,UMCommonPrefixSubName,__FILE__,__PRETTY_FUNCTION__,__LINE__,format,##__VA_ARGS__) 103 | #define UMCommonPrefixSubNameLogDebug(format, ...) UMCommonPrefixSubNameLog(1,8,UMCommonPrefixSubName,__FILE__,__PRETTY_FUNCTION__,__LINE__,format,##__VA_ARGS__) 104 | #define UMCommonPrefixSubNameLogVerbose(format, ...) UMCommonPrefixSubNameLog(1,16,UMCommonPrefixSubName,__FILE__,__PRETTY_FUNCTION__,__LINE__,format,##__VA_ARGS__) 105 | 106 | #define UMCommonPrefixSubName1 ".Core" 107 | #define UMCommonPrefixSubNameLogError1(format, ...) UMCommonPrefixSubNameLog(1,1,UMCommonPrefixSubName1,__FILE__,__PRETTY_FUNCTION__,__LINE__,format,##__VA_ARGS__) 108 | #define UMCommonPrefixSubNameLogWarn1(format, ...) UMCommonPrefixSubNameLog(1,2,UMCommonPrefixSubName1,__FILE__,__PRETTY_FUNCTION__,__LINE__,format,##__VA_ARGS__) 109 | #define UMCommonPrefixSubNameLogInfo1(format, ...) UMCommonPrefixSubNameLog(1,4,UMCommonPrefixSubName1,__FILE__,__PRETTY_FUNCTION__,__LINE__,format,##__VA_ARGS__) 110 | #define UMCommonPrefixSubNameLogDebug1(format, ...) UMCommonPrefixSubNameLog(1,8,UMCommonPrefixSubName1,__FILE__,__PRETTY_FUNCTION__,__LINE__,format,##__VA_ARGS__) 111 | #define UMCommonPrefixSubNameLogVerbose1(format, ...) UMCommonPrefixSubNameLog(1,16,UMCommonPrefixSubName1,__FILE__,__PRETTY_FUNCTION__,__LINE__,format,##__VA_ARGS__) 112 | 113 | 114 | #define UMCommonPrefixSubNameLogError2(UMCommonPrefixSubName2,format, ...) UMCommonPrefixSubNameLog(1,1,UMCommonPrefixSubName2,__FILE__,__PRETTY_FUNCTION__,__LINE__,format,##__VA_ARGS__) 115 | #define UMCommonPrefixSubNameLogWarn2(UMCommonPrefixSubName2,format, ...) UMCommonPrefixSubNameLog(1,2,UMCommonPrefixSubName2,__FILE__,__PRETTY_FUNCTION__,__LINE__,format,##__VA_ARGS__) 116 | #define UMCommonPrefixSubNameLogInfo2(UMCommonPrefixSubName2,format, ...) UMCommonPrefixSubNameLog(1,4,UMCommonPrefixSubName2,__FILE__,__PRETTY_FUNCTION__,__LINE__,format,##__VA_ARGS__) 117 | #define UMCommonPrefixSubNameLogDebug2(UMCommonPrefixSubName2,format, ...) UMCommonPrefixSubNameLog(1,8,UMCommonPrefixSubName2,__FILE__,__PRETTY_FUNCTION__,__LINE__,format,##__VA_ARGS__) 118 | #define UMCommonPrefixSubNameLogVerbose2(UMCommonPrefixSubName2,format, ...) UMCommonPrefixSubNameLog(1,16,UMCommonPrefixSubName2,__FILE__,__PRETTY_FUNCTION__,__LINE__,format,##__VA_ARGS__) 119 | //UMAnalytics的日志宏 120 | //简易函数类似于系统的NSLog函数,线程安全 121 | #define UMAnalyticsLogError(format, ...) UMCommonLog(2,1,__FILE__,__PRETTY_FUNCTION__,__LINE__,format,##__VA_ARGS__) 122 | #define UMAnalyticsLogWarn(format, ...) UMCommonLog(2,2,__FILE__,__PRETTY_FUNCTION__,__LINE__,format,##__VA_ARGS__) 123 | #define UMAnalyticsLogInfo(format, ...) UMCommonLog(2,4,__FILE__,__PRETTY_FUNCTION__,__LINE__,format,##__VA_ARGS__) 124 | #define UMAnalyticsLogDebug(format, ...) UMCommonLog(2,8,__FILE__,__PRETTY_FUNCTION__,__LINE__,format,##__VA_ARGS__) 125 | #define UMAnalyticsLogVerbose(format, ...) UMCommonLog(2,16,__FILE__,__PRETTY_FUNCTION__,__LINE__,format,##__VA_ARGS__) 126 | 127 | //UMPush 的日志宏 128 | //简易函数类似于系统的NSLog函数,线程安全 129 | #define UMPushLogError(format, ...) UMCommonLog(3,1,__FILE__,__PRETTY_FUNCTION__,__LINE__,format,##__VA_ARGS__) 130 | #define UMPushLogWarn(format, ...) UMCommonLog(3,2,__FILE__,__PRETTY_FUNCTION__,__LINE__,format,##__VA_ARGS__) 131 | #define UMPushLogInfo(format, ...) UMCommonLog(3,4,__FILE__,__PRETTY_FUNCTION__,__LINE__,format,##__VA_ARGS__) 132 | #define UMPushLogDebug(format, ...) UMCommonLog(3,8,__FILE__,__PRETTY_FUNCTION__,__LINE__,format,##__VA_ARGS__) 133 | #define UMPushLogVerbose(format, ...) UMCommonLog(3,16,__FILE__,__PRETTY_FUNCTION__,__LINE__,format,##__VA_ARGS__) 134 | 135 | //UMShare 的日志宏 136 | //简易函数类似于系统的NSLog函数,线程安全 137 | #define UMShareLogError(format, ...) UMCommonLog(4,1,__FILE__,__PRETTY_FUNCTION__,__LINE__,format,##__VA_ARGS__) 138 | #define UMShareLogWarn(format, ...) UMCommonLog(4,2,__FILE__,__PRETTY_FUNCTION__,__LINE__,format,##__VA_ARGS__) 139 | #define UMShareLogInfo(format, ...) UMCommonLog(4,4,__FILE__,__PRETTY_FUNCTION__,__LINE__,format,##__VA_ARGS__) 140 | #define UMShareLogDebug(format, ...) UMCommonLog(4,8,__FILE__,__PRETTY_FUNCTION__,__LINE__,format,##__VA_ARGS__) 141 | #define UMShareLogVerbose(format, ...) UMCommonLog(4,16,__FILE__,__PRETTY_FUNCTION__,__LINE__,format,##__VA_ARGS__) 142 | #endif 143 | -------------------------------------------------------------------------------- /ios/RNUMCommon/UMShare/UMShare: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yolinsoft/react-native-dk-umeng/d7fda29c2ba35bc40f06e6ae3702245ed784d175/ios/RNUMCommon/UMShare/UMShare -------------------------------------------------------------------------------- /ios/RNUMCommon/UMShare/UMShare.h: -------------------------------------------------------------------------------- 1 | // 2 | // UMSocialCore.h 3 | // UMSocialCore 4 | // 5 | // Created by 张军华 on 16/8/24. 6 | // Copyright © 2016年 张军华. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //! Project version number for UMSocialCore. 12 | FOUNDATION_EXPORT double UMSocialCoreVersionNumber; 13 | 14 | //! Project version string for UMSocialCore. 15 | FOUNDATION_EXPORT const unsigned char UMSocialCoreVersionString[]; 16 | 17 | // In this header, you should import all the public headers of your framework using statements like #import 18 | 19 | //base handle 20 | #import 21 | 22 | //UI 23 | //#import 24 | //#import 25 | 26 | //save socialData 27 | #import 28 | 29 | //ImageUtil 30 | #import 31 | 32 | //shareMessageObject 33 | #import 34 | #import 35 | 36 | //core Social 37 | #import 38 | #import 39 | #import 40 | #import 41 | 42 | //img ImageUtils 43 | #import 44 | 45 | //UMSocial log 46 | #import 47 | 48 | 49 | //watermark 50 | #import 51 | 52 | 53 | -------------------------------------------------------------------------------- /ios/RNUMCommon/UMShare/UMSocialCoreImageUtils.h: -------------------------------------------------------------------------------- 1 | // 2 | // UMSocialCoreImageUtils.h 3 | // UMSocialCore 4 | // 5 | // Created by 张军华 on 16/9/18. 6 | // Copyright © 2016年 UMeng. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | 13 | @interface UMSocialCoreImageUtils : NSObject 14 | 15 | + (UIImage *)fixOrientation:(UIImage *)sourceImage; 16 | 17 | + (UIImage *)imageWithColor:(UIColor *)color; 18 | 19 | + (UIImage *)imageByScalingImage:(UIImage*)image proportionallyToSize:(CGSize)targetSize; 20 | 21 | + (NSData *)imageDataByCompressImage:(UIImage*)image toLength:(CGFloat)targetLength; 22 | 23 | + (UIImage *)imageByCompressImage:(UIImage*)image toLength:(CGFloat)targetLength; 24 | 25 | @end -------------------------------------------------------------------------------- /ios/RNUMCommon/UMShare/UMSocialDataManager.h: -------------------------------------------------------------------------------- 1 | // 2 | // UMSocialDataManager.h 3 | // UMSocialSDK 4 | // 5 | // Created by umeng on 16/8/9. 6 | // Copyright © 2016年 dongjianxiong. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "UMSocialPlatformConfig.h" 11 | extern NSString *const kUMSocialAuthUID; 12 | extern NSString *const kUMSocialAuthAccessToken; 13 | extern NSString *const kUMSocialAuthExpireDate; 14 | extern NSString *const kUMSocialAuthRefreshToken; 15 | extern NSString *const kUMSocialAuthOpenID; 16 | 17 | @interface UMSocialDataManager : NSObject 18 | 19 | + (UMSocialDataManager *)defaultManager; 20 | 21 | @property (nonatomic, strong, readonly) NSMutableDictionary *allAuthorUserInfo; 22 | 23 | - (void)setAuthorUserInfo:(NSDictionary *)userInfo platform:(UMSocialPlatformType)platformType; 24 | 25 | - (NSDictionary *)getAuthorUserInfoWithPlatform:(UMSocialPlatformType)platformType; 26 | 27 | - (void)deleteAuthorUserInfoWithPlatform:(UMSocialPlatformType)platformType; 28 | 29 | - (BOOL)isAuth:(UMSocialPlatformType)platformType; 30 | 31 | - (void)clearAllAuthorUserInfo; 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /ios/RNUMCommon/UMShare/UMSocialGlobal.h: -------------------------------------------------------------------------------- 1 | // 2 | // UMSocialGlobal.h 3 | // UMSocialSDK 4 | // 5 | // Created by 张军华 on 16/8/16. 6 | // Copyright © 2016年 dongjianxiong. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | /** 13 | * UMSocial的全局配置文件 14 | */ 15 | 16 | 17 | @class UMSocialWarterMarkConfig; 18 | 19 | /** 20 | * 用来设置UMSocial的全局设置变量 21 | */ 22 | @interface UMSocialGlobal: NSObject 23 | 24 | + (UMSocialGlobal *)shareInstance; 25 | 26 | /** 27 | * 是否用cocos2dx,0-没有使用 1-使用cocos2dx 默认为0 28 | */ 29 | @property(atomic,readwrite, assign)NSInteger use_coco2dx; 30 | 31 | /** 32 | * 统计的主题,默认为:UMSocialDefault 33 | */ 34 | @property(atomic,readwrite,copy)NSString* dc; 35 | 36 | /** 37 | * 是否请求的回流统计请求,默认为不请求 38 | */ 39 | @property(atomic,readwrite,assign)BOOL isUrlRequest; 40 | 41 | /** 42 | * type字符串 43 | * @discuss type是新加入的字段,目前默认值为@"native" 44 | */ 45 | @property(atomic,readwrite, copy)NSString* type; 46 | 47 | 48 | /** 49 | * UMSocial的版本号 50 | * 51 | * @return 返回当前的版本号 52 | */ 53 | +(NSString*)umSocialSDKVersion; 54 | 55 | 56 | /** 57 | * 对平台的分享文本的时候,做规定的截断,默认开启 58 | * @discuss 针对特定平台(比如:微信,qq,sina等)对当前的分享信息中的文本截断到合理的位置从而能成功分享 59 | */ 60 | @property(atomic,readwrite,assign)BOOL isTruncateShareText; 61 | 62 | /** 63 | * 当前网络请求是否用https 64 | * @discuss 针对ios9系统以后强制使用https的网络请求,针对分享的网络图片都必须是https的网络图片(此为苹果官方要求) 65 | * @discuss 该函数默认开启https请求 66 | * @discuss 如果开启ios9的请求后,自动会过滤ios的http的请求,并返回错误。 67 | * 68 | */ 69 | @property(atomic,readwrite,assign)BOOL isUsingHttpsWhenShareContent; 70 | 71 | 72 | /** 73 | * 是否清除缓存在获得用户资料的时候 74 | * 默认设置为YES,代表请求用户的时候需要请求缓存 75 | * NO,代表不清楚缓存,用缓存的数据请求用户数据 76 | */ 77 | @property(atomic,readwrite,assign)BOOL isClearCacheWhenGetUserInfo; 78 | 79 | 80 | /** 81 | * 添加水印功能 82 | * @note 此功能为6.2版本以后的功能 83 | * @discuss 此函数默认关闭 NO - 关闭水印 YES - 打开水印 84 | * @discuss 设置此函数为YES后,必须要设置warterMarkConfig,来配置图片水印和字符串水印,如果不配置,就会用默认的[UMSocialWarterMarkConfig defaultWarterMarkConfig]来显示水印 85 | */ 86 | @property(atomic,readwrite,assign)BOOL isUsingWaterMark; 87 | 88 | /** 89 | * 添加水印的配置类 90 | * @note 此功能为6.2版本以后的功能 91 | * @discuss 设置isUsingWaterMark此函数为YES后,必须要设置warterMarkConfig,来配置图片水印和字符串水印 92 | */ 93 | @property(nonatomic,readwrite,strong)UMSocialWarterMarkConfig* warterMarkConfig; 94 | 95 | 96 | /** 97 | * 废弃 API 98 | */ 99 | @property(atomic,readwrite,copy)NSString* thumblr_Tag; 100 | 101 | @end 102 | 103 | -------------------------------------------------------------------------------- /ios/RNUMCommon/UMShare/UMSocialHandler.h: -------------------------------------------------------------------------------- 1 | // 2 | // UMSShareDataTypeTableViewController.h 3 | // SocialSDK 4 | // 5 | // Created by umeng on 16/4/14. 6 | // Copyright © 2016年 dongjianxiong. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "UMSocialPlatformConfig.h" 11 | #import "UMSocialPlatformProvider.h" 12 | 13 | 14 | extern NSString *const UMSocialErrorDomain; 15 | extern NSString *const UMSocialShareDataTypeIllegalMessage; 16 | 17 | @class UMSocialHandlerConfig; 18 | 19 | /** 20 | * 实现所有平台的基类 21 | * @discuss 22 | * 前提条件:需要在主工程配置 other link flag -ObjC 23 | * 所有实现UMSocialHandler对应平台类型子类,需要重写如下方法: 24 | * 1.+(NSArray*) socialPlatformTypes; 返回对应平台的类型的数组,此处用数组是为了在微信和qq的平台是可以有不同的平台类型(微信,朋友圈等)与统一handler公用 25 | * 2.重写load函数: 26 | * 27 | * 代码示例: 28 | * +(void)load 29 | * { 30 | * [super load];//必须调用 31 | * } 32 | * 33 | * 重载后保证调用基类的[UMSocialHandler load] 34 | * 3.重写defaultManager单例类方法,保证运行时能找到defaultManager来获得当前的单例方法,保证其唯一性。 35 | */ 36 | @interface UMSocialHandler : NSObject 37 | 38 | #pragma mark - 子类需要重载的类 39 | +(void)load; 40 | +(NSArray*) socialPlatformTypes; 41 | + (instancetype)defaultManager; 42 | 43 | #pragma mark - 44 | 45 | @property (nonatomic, copy) NSString *appID; 46 | 47 | @property (nonatomic, copy) NSString *appSecret; 48 | 49 | @property (nonatomic, copy) NSString *redirectURL; 50 | 51 | /** 52 | * 当前ViewController(用于一些特定平台弹出相应的页面,默认使用当前ViewController) 53 | * since 6.3把currentViewController修改为弱引用,防止用户传入后强引用用户传入的UIViewController,导致内存不释放, 54 | * 注意:如果传入currentViewController的时候,一定要保证在(执行对应的分享,授权,获得用户信息的接口需要传入此接口的时候)存在,否则导致弱引用为nil,没有弹出界面的效果。 55 | */ 56 | @property (nonatomic, weak) UIViewController *currentViewController; 57 | 58 | @property (nonatomic, copy) UMSocialRequestCompletionHandler shareCompletionBlock; 59 | 60 | @property (nonatomic, copy) UMSocialRequestCompletionHandler authCompletionBlock; 61 | 62 | @property (nonatomic, copy) UMSocialRequestCompletionHandler userinfoCompletionBlock; 63 | 64 | 65 | -(BOOL)searchForURLSchemeWithPrefix:(NSString *)prefix; 66 | -(void)setAppId:(NSString *)appID appSecret:(NSString *)secret url:(NSString *)url; 67 | -(void)saveuid:(NSString *)uid openid:(NSString *)openid accesstoken:(NSString *)token refreshtoken:(NSString *)retoken expiration:(id )expiration; 68 | 69 | #pragma mark - 6.0.3新加入的平台配置类 70 | @property(nonatomic,readonly,strong)UMSocialHandlerConfig* handlerConfig; 71 | 72 | 73 | @end 74 | 75 | 76 | /** 77 | * 针对平台限制的类别 78 | */ 79 | @interface UMSocialHandler (UMSocialLimit) 80 | 81 | /** 82 | * 检查对应平台的数据数据是否超过限制 83 | * 84 | * @param text 源文本 85 | * @param textLimit 限制文本的大小 86 | * 87 | * @return YES 代表没有限制,NO 代表超过限制 88 | */ 89 | -(BOOL) checkText:(NSString*)text withTextLimit:(NSUInteger)textLimit; 90 | 91 | 92 | /** 93 | * 检查对应平台的数据数据是否超过限制 94 | * 95 | * @param data 源文本 96 | * @param dataLimit 限制文本的大小 97 | * 98 | * @return YES 代表没有限制,NO 代表超过限制 99 | */ 100 | -(BOOL) checkData:(NSData*)data withDataLimit:(NSUInteger)dataLimit; 101 | 102 | /** 103 | * 对应平台超过限制,就截断文本 104 | * 105 | * @param text 源文本 106 | * @param textLimit 限制文本的大小 107 | * 108 | * @return 返回的截断的文本 109 | */ 110 | -(NSString*)truncationText:(NSString*)text withTextLimit:(NSUInteger)textLimit; 111 | 112 | 113 | /** 114 | * 压缩对应平台的图片数据到限制发送的大小 115 | * 116 | * @param imageData 对应的图片数据 117 | * @param imageLimit 限制图片的大小 118 | * 119 | * @return 新的压缩的数据 120 | * @dicuss 当前图片小于对应平台的限制大小就返回本身,反之就压缩到指定大小以下发送 121 | */ 122 | -(NSData*)compressImageData:(NSData*)imageData withImageLimit:(NSUInteger)imageLimit; 123 | 124 | @end 125 | 126 | 127 | #pragma mark - 6.0.3新增的配置类,用于限制分享类型和分享的内容 128 | 129 | /** 130 | * UMeng 分享类型配置信息的基类 131 | */ 132 | @interface UMSocialShareObjectConfig : NSObject 133 | 134 | /** 135 | * 标题 136 | * @note 标题的长度依各个平台的要求而定 137 | */ 138 | @property (nonatomic, readwrite,assign) NSUInteger titleLimit; 139 | 140 | /** 141 | * 描述 142 | * @note 描述内容的长度依各个平台的要求而定 143 | */ 144 | @property (nonatomic, readwrite,assign) NSUInteger descrLimit; 145 | 146 | /** 147 | * 缩略图数据的大小 148 | */ 149 | @property (nonatomic, readwrite,assign) NSUInteger thumbImageDataLimit; 150 | 151 | /** 152 | * 缩略图URL的大小 153 | */ 154 | @property (nonatomic, readwrite,assign) NSUInteger thumbImageUrlLimit; 155 | 156 | 157 | /** 158 | * 点击多媒体内容之后呼起第三方应用特定页面的scheme 159 | * @warning 长度小于255 160 | * //sina平台有此字段限制 161 | * @discuss 此字段目前不用 162 | */ 163 | //@property (nonatomic, strong) NSString *schemeLimit; 164 | 165 | /** 166 | * @note 长度不能超过64字节 167 | * //微信平台有此字段 168 | * @discuss 此字段目前不用 169 | */ 170 | //@property (nonatomic, retain) NSString *mediaTagName; 171 | 172 | @end 173 | /** 174 | * 分享文本类型的配置 175 | * 176 | */ 177 | @interface UMSocialShareTextObjectConfig : UMSocialShareObjectConfig 178 | 179 | /** 180 | * 文本内容的限制 181 | */ 182 | @property(nonatomic,readwrite,assign)NSUInteger textLimit; 183 | 184 | @end 185 | 186 | 187 | /** 188 | * 分享图片的类型配置 189 | */ 190 | @interface UMSocialShareImageObjectConfig : UMSocialShareObjectConfig 191 | 192 | /** 193 | * 缩略图数据的大小 194 | */ 195 | @property (nonatomic, readwrite,assign) NSUInteger shareImageDataLimit; 196 | 197 | /** 198 | * 缩略图数据的URL大小 199 | */ 200 | @property (nonatomic, readwrite,assign) NSUInteger shareImageURLLimit; 201 | 202 | @end 203 | 204 | 205 | /** 206 | * 分享音乐的类型配置 207 | */ 208 | @interface UMSocialShareMusicObjectConfig : UMSocialShareObjectConfig 209 | 210 | /** 211 | * 音乐网页的url地址 212 | */ 213 | @property (nonatomic, readwrite,assign)NSUInteger musicUrlLimit; 214 | 215 | /** 216 | * 音乐lowband网页的url地址 217 | */ 218 | @property (nonatomic, readwrite,assign)NSUInteger musicLowBandUrlLimit; 219 | 220 | /** 221 | * 音乐数据url地址 222 | */ 223 | @property (nonatomic, readwrite,assign)NSUInteger musicDataUrlLimit; 224 | 225 | /** 226 | * 音乐lowband数据url地址 227 | */ 228 | @property (nonatomic, readwrite,assign)NSUInteger musicLowBandDataUrlLimit; 229 | 230 | @end 231 | 232 | /** 233 | * 分享视频的类型配置 234 | */ 235 | @interface UMSocialShareVideoObjectConfig : UMSocialShareObjectConfig 236 | 237 | /** 238 | * 视频网页的url 239 | */ 240 | @property (nonatomic, readwrite,assign) NSUInteger videoUrlLimit; 241 | 242 | /** 243 | * 视频lowband网页的url 244 | */ 245 | @property (nonatomic, readwrite,assign) NSUInteger videoLowBandUrlLimit; 246 | 247 | /** 248 | * 视频数据流url 249 | */ 250 | @property (nonatomic, readwrite,assign) NSUInteger videoStreamUrlLimit; 251 | 252 | /** 253 | * 视频lowband数据流url 254 | */ 255 | @property (nonatomic, readwrite,assign) NSUInteger videoLowBandStreamUrlLimit; 256 | 257 | @end 258 | 259 | /** 260 | * 分享webURL 261 | */ 262 | @interface UMSocialShareWebpageObjectConfig : UMSocialShareObjectConfig 263 | 264 | /** 265 | * 网页的url地址 266 | */ 267 | @property (nonatomic, readwrite,assign) NSUInteger webpageUrlLimit; 268 | 269 | @end 270 | 271 | /** 272 | * 分享Email的类型配置 273 | */ 274 | @interface UMSocialShareEmailObjectConfig : UMSocialShareObjectConfig 275 | 276 | /** 277 | * 接收人 278 | */ 279 | @property (nonatomic, readwrite,assign) NSUInteger toRecipientLimit; 280 | 281 | /** 282 | * 抄送人 283 | */ 284 | @property (nonatomic, readwrite,assign) NSUInteger ccRecipientLimit; 285 | 286 | /** 287 | * 密送人 288 | */ 289 | @property (nonatomic, readwrite,assign) NSUInteger bccRecipientLimit; 290 | 291 | /** 292 | * 文本内容 293 | */ 294 | @property (nonatomic, readwrite,assign) NSUInteger emailContentLimit; 295 | 296 | /** 297 | * 图片大小 298 | */ 299 | @property (nonatomic, readwrite,assign) NSUInteger emailImageDataLimit; 300 | 301 | /** 302 | * 图片URL大小 303 | */ 304 | @property (nonatomic, readwrite,assign) NSUInteger emailImageUrlLimit; 305 | 306 | /** 307 | * 文件(NSData) 308 | */ 309 | @property (nonatomic, readwrite,assign) NSUInteger emailSendDataLimit; 310 | 311 | /** 312 | * 允许的文件格式 313 | */ 314 | @property (nonatomic, readwrite,strong) NSArray *fileType; 315 | 316 | /** 317 | * 文件名,(例如图片 imageName.png, 文件名后要跟文件后缀名,否则没法识别,导致类似图片不显示的问题) 318 | */ 319 | @property (nonatomic, readwrite,assign) NSUInteger fileNameLimit; 320 | 321 | 322 | @end 323 | 324 | /** 325 | * 分享Email的类型配置 326 | */ 327 | @interface UMSocialShareSmsObjectConfig : UMSocialShareObjectConfig 328 | 329 | /** 330 | * 接收人 331 | */ 332 | @property (nonatomic, readwrite,assign) NSUInteger recipientLimit; 333 | 334 | /** 335 | * 文本内容 336 | */ 337 | @property (nonatomic, readwrite,assign) NSUInteger smsContentLimit; 338 | 339 | /** 340 | * 图片 341 | */ 342 | @property (nonatomic, readwrite,assign) NSUInteger smsImageDataLimit; 343 | @property (nonatomic, readwrite,assign) NSUInteger smsImageUrlLimit; 344 | 345 | /** 346 | * 文件数据(NSData) 347 | * 必填 348 | */ 349 | @property (nonatomic, readwrite,assign) NSUInteger smsSendDataLimit; 350 | 351 | /** 352 | * 文件格式 353 | * 必填,必须指定数据格式,如png图片格式应传入@"png" 354 | */ 355 | @property (nonatomic, readwrite,strong) NSArray *fileType; 356 | 357 | /** 358 | * 文件名,(例如图片 imageName.png, 文件名后要跟文件后缀名,否则没法识别,导致类似图片不显示的问题) 359 | */ 360 | @property (nonatomic, readwrite,assign) NSUInteger fileNameLimit; 361 | 362 | /** 363 | * 文件地址url 364 | */ 365 | @property (nonatomic, readwrite,assign) NSUInteger fileUrlLimit; 366 | 367 | @end 368 | 369 | /** 370 | * 此配置项是特定平台才有的,比如微信, 371 | */ 372 | @interface UMSocialShareEmotionObjectConfig : UMSocialShareObjectConfig 373 | 374 | //表情的字节大小限制 375 | @property(nonatomic,readwrite,assign)NSUInteger emotionDataLimit; 376 | 377 | @end 378 | 379 | 380 | /** 381 | * 此配置项是特定平台才有的,比如微信, 382 | */ 383 | @interface UMSocialShareFileObjectConfig : UMSocialShareObjectConfig 384 | 385 | @property (nonatomic, readwrite,assign) NSUInteger fileExtensionLimit; 386 | 387 | @property (nonatomic, readwrite,assign) NSUInteger fileDataLimit; 388 | 389 | @end 390 | 391 | /** 392 | * 此配置项是特定平台才有的,比如微信 393 | */ 394 | @interface UMSocialShareExtendObjectConfig : UMSocialShareObjectConfig 395 | 396 | @property (nonatomic, readwrite,assign) NSUInteger urlLimit; 397 | 398 | @property (nonatomic, readwrite,assign) NSUInteger extInfoLimit; 399 | 400 | @property (nonatomic, readwrite,assign) NSUInteger fileDataLimit; 401 | 402 | @end 403 | 404 | 405 | 406 | 407 | /** 408 | * 每个平台的配置信息 409 | * 包括如下: 410 | * 1.对分享内容的限制。 411 | * 412 | */ 413 | @interface UMSocialHandlerConfig : NSObject 414 | 415 | @property(nonatomic,readwrite,strong)UMSocialShareTextObjectConfig* shareTextObjectConfig; 416 | @property(nonatomic,readwrite,strong)UMSocialShareImageObjectConfig* shareImageObjectConfig; 417 | @property(nonatomic,readwrite,strong)UMSocialShareMusicObjectConfig* shareMusicObjectConfig; 418 | @property(nonatomic,readwrite,strong)UMSocialShareVideoObjectConfig* shareVideoObjectConfig; 419 | @property(nonatomic,readwrite,strong)UMSocialShareWebpageObjectConfig* shareWebpageObjectConfig; 420 | @property(nonatomic,readwrite,strong)UMSocialShareEmailObjectConfig* shareEmailObjectConfig; 421 | @property(nonatomic,readwrite,strong)UMSocialShareSmsObjectConfig* shareSmsObjectConfig; 422 | @property(nonatomic,readwrite,strong)UMSocialShareEmotionObjectConfig* shareEmotionObjectConfig; 423 | @property(nonatomic,readwrite,strong)UMSocialShareFileObjectConfig* shareFileObjectConfig; 424 | @property(nonatomic,readwrite,strong)UMSocialShareExtendObjectConfig* shareExtendObjectConfig; 425 | 426 | //检查输入的text是否符合对应平台的输入 427 | +(BOOL) checkText:(NSString*)text withTextLimit:(NSUInteger)textLimit; 428 | +(BOOL) checkData:(NSData*)data withDataLimit:(NSUInteger)dataLimit; 429 | +(NSString*) truncationText:(NSString*)text withTextLimit:(NSUInteger)textLimit; 430 | 431 | //压缩图片 432 | + (NSData *)compressImageData:(NSData*)imageData toLength:(CGFloat)imageLimit; 433 | + (NSData *)compressImage:(UIImage*)image toLength:(CGFloat)imageLimit; 434 | 435 | @end 436 | -------------------------------------------------------------------------------- /ios/RNUMCommon/UMShare/UMSocialImageUtil.h: -------------------------------------------------------------------------------- 1 | // 2 | // UMSocialImageUtil.h 3 | // UMSocialSDK 4 | // 5 | // Created by wangfei on 16/8/12. 6 | // Copyright © 2016年 dongjianxiong. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | @interface UMSocialImageUtil : NSObject 12 | +(UIImage*)scaleImage:(UIImage *) image ToSize:(CGSize)size; 13 | @end 14 | -------------------------------------------------------------------------------- /ios/RNUMCommon/UMShare/UMSocialManager.h: -------------------------------------------------------------------------------- 1 | // 2 | // UMComPlatformProviderManager.h 3 | // UMSocialSDK 4 | // 5 | // Created by 张军华 on 16/8/5. 6 | // Copyright © 2016年 dongjianxiong. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "UMSocialPlatformProvider.h" 11 | #import "UMSocialGlobal.h" 12 | @class UMSocialMessageObject; 13 | @interface UMSocialManager : NSObject 14 | 15 | +(instancetype)defaultManager; 16 | 17 | /** 18 | 友盟appkey 19 | */ 20 | @property(nonatomic,strong)NSString* umSocialAppkey; 21 | @property(nonatomic,strong)NSString* umSocialAppSecret; 22 | 23 | /** 24 | 返回当前有效(安装并是可用的)平台列表 25 | */ 26 | @property(nonatomic,readonly,strong) NSArray * platformTypeArray; 27 | 28 | 29 | /** 30 | * 打开日志 31 | * 32 | * @param isOpen YES代表打开,No代表关闭 33 | */ 34 | -(void) openLog:(BOOL)isOpen; 35 | 36 | /** 37 | * 设置平台的appkey 38 | * 39 | * @param platformType 平台类型 @see UMSocialPlatformType 40 | * @param appKey 第三方平台的appKey(QQ平台为appID) 41 | * @param appSecret 第三方平台的appSecret(QQ平台为appKey) 42 | * @param redirectURL redirectURL 43 | */ 44 | - (BOOL)setPlaform:(UMSocialPlatformType)platformType 45 | appKey:(NSString *)appKey 46 | appSecret:(NSString *)appSecret 47 | redirectURL:(NSString *)redirectURL; 48 | 49 | 50 | /** 51 | * 设置分享平台 52 | * 53 | * @param platformType 平台类型 @see UMSocialPlatformType 54 | * @param messageObject 分享的content @see UMSocialMessageObject 55 | * @param currentViewController 用于弹出类似邮件分享、短信分享等这样的系统页面 56 | * @param completion 回调 57 | * @discuss currentViewController 只正对sms,email等平台需要传入viewcontroller的平台,其他不需要的平台可以传入nil 58 | */ 59 | - (void)shareToPlatform:(UMSocialPlatformType)platformType 60 | messageObject:(UMSocialMessageObject *)messageObject 61 | currentViewController:(id)currentViewController 62 | completion:(UMSocialRequestCompletionHandler)completion; 63 | 64 | /** 65 | * 取消授权 66 | * 67 | * @param platformType 平台类型 @see UMSocialPlatformType 68 | * @param completion 回调 69 | */ 70 | - (void)cancelAuthWithPlatform:(UMSocialPlatformType)platformType 71 | completion:(UMSocialRequestCompletionHandler)completion; 72 | 73 | /** 74 | * 授权并获取用户信息 75 | * @param platformType 平台类型 @see UMSocialPlatformType 76 | * @param currentViewController 用于弹出类似邮件分享、短信分享等这样的系统页面 77 | * @param completion 回调 78 | */ 79 | - (void)getUserInfoWithPlatform:(UMSocialPlatformType)platformType 80 | currentViewController:(id)currentViewController 81 | completion:(UMSocialRequestCompletionHandler)completion; 82 | 83 | /** 84 | * 获得从sso或者web端回调到本app的回调 85 | * 86 | * @param url 第三方sdk的打开本app的回调的url 87 | * 88 | * @return 是否处理 YES代表处理成功,NO代表不处理 89 | */ 90 | -(BOOL)handleOpenURL:(NSURL *)url; 91 | 92 | /** 93 | * 获得从sso或者web端回调到本app的回调 94 | * 95 | * @param url 第三方sdk的打开本app的回调的url 96 | * @param sourceApplication 回调的源程序 97 | * @param annotation annotation 98 | * 99 | * @return 是否处理 YES代表处理成功,NO代表不处理 100 | * 101 | * @note 此函数在6.3版本加入 102 | */ 103 | -(BOOL)handleOpenURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation; 104 | 105 | /** 106 | * 获得从sso或者web端回调到本app的回调 107 | * 108 | * @param url 第三方sdk的打开本app的回调的url 109 | * @param options 回调的参数 110 | * 111 | * @return 是否处理 YES代表处理成功,NO代表不处理 112 | * 113 | * @note 此函数在6.3版本加入 114 | */ 115 | -(BOOL)handleOpenURL:(NSURL *)url options:(NSDictionary*)options; 116 | 117 | 118 | /** 119 | * 动态的增加用户自定义的PlatformProvider 120 | * 121 | * @param userDefinePlatformProvider 用户自定义的userDefinePlatformProvider必须实现UMSocialPlatformProvider 122 | * @param platformType 平台类型 @see platformType platformType的有效范围在 (UMSocialPlatformType_UserDefine_Begin,UMSocialPlatformType_UserDefine_End)之间 123 | * 124 | * @return YES代表返回成功,NO代表失败 125 | * @disuss 在调用此函数前,必须先设置对应的平台的配置信息 @see - (BOOL)setPlaform:(UMSocialPlatformType)platformType appKey:(NSString *)appKey appSecret:(NSString *)appSecret redirectURL:(NSString *)redirectURL; 126 | */ 127 | -(BOOL)addAddUserDefinePlatformProvider:(id)userDefinePlatformProvider 128 | withUserDefinePlatformType:(UMSocialPlatformType)platformType; 129 | 130 | 131 | /** 132 | * 获得对应的平台类型platformType的PlatformProvider 133 | * 134 | * @param platformType 平台类型 @see platformType 135 | * 136 | * @return 返回继承UMSocialPlatformProvider的handle 137 | */ 138 | -(id)platformProviderWithPlatformType:(UMSocialPlatformType)platformType; 139 | 140 | 141 | 142 | /** 143 | * 动态的删除不想显示的平台,不管是预定义还是用户自定义的 144 | * 145 | * @param platformTypeArray 平台类型数组 146 | */ 147 | -(void) removePlatformProviderWithPlatformTypes:(NSArray *)platformTypeArray; 148 | 149 | /** 150 | * 动态的删除PlatformProvider,不管是预定义还是用户自定义的 151 | * 152 | * @param platformType 平台类型 @see UMSocialPlatformType 153 | */ 154 | -(void) removePlatformProviderWithPlatformType:(UMSocialPlatformType)platformType; 155 | 156 | 157 | /** 158 | * 平台是否安装 159 | * 160 | * @param platformType 平台类型 @see UMSocialPlatformType 161 | * 162 | * @return YES 代表安装,NO 代表未安装 163 | * @note 调用前请检查是否配置好平台相关白名单: http://dev.umeng.com/social/ios/quick-integration#1_3 164 | * 在判断QQ空间的App的时候,QQApi判断会出问题 165 | */ 166 | -(BOOL) isInstall:(UMSocialPlatformType)platformType; 167 | 168 | /** 169 | * 当前平台是否支持分享 170 | * 171 | * @param platformType 平台类型 @see UMSocialPlatformType 172 | * 173 | * @return YES代表支持,NO代表不支持 174 | */ 175 | -(BOOL) isSupport:(UMSocialPlatformType)platformType; 176 | 177 | 178 | #pragma mark - NOT COMMON METHOD 179 | /** 180 | * 授权平台 (此方法仅获取授权token,不包含获取用户信息。推荐使用上面的 getUserInfoWithPlatform... 接口获取授权及用户信息) 181 | * 182 | * @param platformType 平台类型 @see UMSocialPlatformType 183 | * @param currentViewController 用于弹出类似邮件分享、短信分享等这样的系统页面 184 | * @discuss currentViewController 只对sms,email等平台需要传入viewcontroller的平台,其他不需要的平台可以传入nil 185 | * @param completion 回调 186 | */ 187 | - (void)authWithPlatform:(UMSocialPlatformType)platformType 188 | currentViewController:(UIViewController *)currentViewController 189 | completion:(UMSocialRequestCompletionHandler)completion; 190 | 191 | @end 192 | 193 | -------------------------------------------------------------------------------- /ios/RNUMCommon/UMShare/UMSocialMessageObject.h: -------------------------------------------------------------------------------- 1 | // 2 | // UMSocialMessageObject.h 3 | // SocialSDK 4 | // 5 | // Created by umeng on 16/4/22. 6 | // Copyright © 2016年 dongjianxiong. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | 13 | @interface UMSocialMessageObject : NSObject 14 | 15 | 16 | /** 17 | * 文本标题 18 | * @disucss v6.0.3版本后增加的一个字段, 19 | * @disucss 该字段目前只有Tumblr平台会使用到。 20 | * @discuss 该字段以后会在需要文本title字段中扩展,具体请参看官方文档。 21 | */ 22 | @property (nonatomic,copy)NSString* title; 23 | 24 | /** 25 | * text 文本内容 26 | * @note 非纯文本分享文本 27 | */ 28 | @property (nonatomic, copy) NSString *text; 29 | 30 | /** 31 | * 分享的所媒体内容对象 32 | */ 33 | @property (nonatomic, strong) id shareObject; 34 | 35 | /** 36 | * 其他相关参数,见相应平台说明 37 | */ 38 | @property (nonatomic, strong) NSDictionary *moreInfo; 39 | 40 | + (UMSocialMessageObject *)messageObject; 41 | 42 | + (UMSocialMessageObject *)messageObjectWithMediaObject:(id)mediaObject; 43 | 44 | 45 | @end 46 | 47 | 48 | @interface UMShareObject : NSObject 49 | 50 | /** 51 | * 标题 52 | * @note 标题的长度依各个平台的要求而定 53 | */ 54 | @property (nonatomic, copy) NSString *title; 55 | 56 | /** 57 | * 描述 58 | * @note 描述内容的长度依各个平台的要求而定 59 | */ 60 | @property (nonatomic, copy) NSString *descr; 61 | 62 | /** 63 | * 缩略图 UIImage或者NSData类型或者NSString类型(图片url) 64 | */ 65 | @property (nonatomic, strong) id thumbImage; 66 | 67 | /** 68 | * @param title 标题 69 | * @param descr 描述 70 | * @param thumImage 缩略图(UIImage或者NSData类型,或者image_url) 71 | * 72 | */ 73 | + (id)shareObjectWithTitle:(NSString *)title 74 | descr:(NSString *)descr 75 | thumImage:(id)thumImage; 76 | 77 | + (void)um_imageDataWithImage:(id)image completion:(void (^)(NSData *image))completion; 78 | 79 | #pragma mark - 6.0.3新版本的函数 80 | + (void)um_imageDataWithImage:(id)image withCompletion:(void (^)(NSData *imageData,NSError* error))completion; 81 | 82 | @end 83 | 84 | 85 | 86 | @interface UMShareImageObject : UMShareObject 87 | 88 | /** 分享单个图片(支持UIImage,NSdata以及图片链接Url NSString类对象集合) 89 | * @note 图片大小根据各个平台限制而定 90 | */ 91 | @property (nonatomic, retain) id shareImage; 92 | 93 | /** 分享图片数组,支持 UIImage、NSData 类型 94 | * @note 仅支持分享到: 95 | * 微博平台,最多可分享9张图片 96 | * QZone平台,最多可分享20张图片 97 | */ 98 | @property (nonatomic, copy) NSArray *shareImageArray; 99 | 100 | /** 101 | * @param title 标题 102 | * @param descr 描述 103 | * @param thumImage 缩略图(UIImage或者NSData类型,或者image_url) 104 | * 105 | */ 106 | + (UMShareImageObject *)shareObjectWithTitle:(NSString *)title 107 | descr:(NSString *)descr 108 | thumImage:(id)thumImage; 109 | 110 | @end 111 | 112 | @interface UMShareMusicObject : UMShareObject 113 | 114 | /** 音乐网页的url地址 115 | * @note 长度不能超过10K 116 | */ 117 | @property (nonatomic, retain) NSString *musicUrl; 118 | /** 音乐lowband网页的url地址 119 | * @note 长度不能超过10K 120 | */ 121 | @property (nonatomic, retain) NSString *musicLowBandUrl; 122 | /** 音乐数据url地址 123 | * @note 长度不能超过10K 124 | */ 125 | @property (nonatomic, retain) NSString *musicDataUrl; 126 | 127 | /**音乐lowband数据url地址 128 | * @note 长度不能超过10K 129 | */ 130 | @property (nonatomic, retain) NSString *musicLowBandDataUrl; 131 | 132 | /** 133 | * @param title 标题 134 | * @param descr 描述 135 | * @param thumImage 缩略图(UIImage或者NSData类型,或者image_url) 136 | * 137 | */ 138 | + (UMShareMusicObject *)shareObjectWithTitle:(NSString *)title 139 | descr:(NSString *)descr 140 | thumImage:(id)thumImage; 141 | 142 | @end 143 | 144 | 145 | @interface UMShareVideoObject : UMShareObject 146 | 147 | /** 148 | 视频网页的url 149 | 150 | @warning 不能为空且长度不能超过255 151 | */ 152 | @property (nonatomic, strong) NSString *videoUrl; 153 | 154 | /** 155 | 视频lowband网页的url 156 | 157 | @warning 长度不能超过255 158 | */ 159 | @property (nonatomic, strong) NSString *videoLowBandUrl; 160 | 161 | /** 162 | 视频数据流url 163 | 164 | @warning 长度不能超过255 165 | */ 166 | @property (nonatomic, strong) NSString *videoStreamUrl; 167 | 168 | /** 169 | 视频lowband数据流url 170 | 171 | @warning 长度不能超过255 172 | */ 173 | @property (nonatomic, strong) NSString *videoLowBandStreamUrl; 174 | 175 | 176 | /** 177 | * @param title 标题 178 | * @param descr 描述 179 | * @param thumImage 缩略图(UIImage或者NSData类型,或者image_url) 180 | * 181 | */ 182 | + (UMShareVideoObject *)shareObjectWithTitle:(NSString *)title 183 | descr:(NSString *)descr 184 | thumImage:(id)thumImage; 185 | 186 | @end 187 | 188 | 189 | @interface UMShareWebpageObject : UMShareObject 190 | 191 | /** 网页的url地址 192 | * @note 不能为空且长度不能超过10K 193 | */ 194 | @property (nonatomic, retain) NSString *webpageUrl; 195 | 196 | /** 197 | * @param title 标题 198 | * @param descr 描述 199 | * @param thumImage 缩略图(UIImage或者NSData类型,或者image_url) 200 | * 201 | */ 202 | + (UMShareWebpageObject *)shareObjectWithTitle:(NSString *)title 203 | descr:(NSString *)descr 204 | thumImage:(id)thumImage; 205 | 206 | @end 207 | 208 | 209 | /*! @brief 分享消息中的邮件分享对象 210 | * 211 | * @see UMSocialMessageObject 212 | */ 213 | 214 | @interface UMShareEmailObject : UMShareObject 215 | 216 | /** 217 | * 主题 218 | */ 219 | @property (nonatomic, strong) NSString *subject; 220 | 221 | /** 222 | * 接收人 223 | */ 224 | @property (nonatomic, strong) NSArray *toRecipients; 225 | 226 | /** 227 | * 抄送人 228 | */ 229 | @property (nonatomic, strong) NSArray *ccRecipients; 230 | 231 | /** 232 | * 密送人 233 | */ 234 | @property (nonatomic, strong) NSArray *bccRecipients; 235 | 236 | /** 237 | * 文本内容 238 | */ 239 | @property (nonatomic, copy) NSString *emailContent; 240 | 241 | /** 242 | * 图片,最好是本地图片(UIImage,或者NSdata) 243 | */ 244 | @property (nonatomic, strong) id emailImage; 245 | 246 | /** 247 | * 发送图片的类型 @see MIME 248 | * 默认 "image/ *" 249 | */ 250 | @property (nonatomic, copy) NSString* emailImageType; 251 | /** 252 | * 发送图片的名字 253 | * 默认 "um_share_image.png" 254 | */ 255 | @property (nonatomic, copy) NSString* emailImageName; 256 | 257 | /** 258 | * 文件(NSData) 259 | */ 260 | @property (nonatomic, strong) NSData *emailSendData; 261 | 262 | /** 263 | * 文件格式 264 | * @see MIME 265 | * 默认 "text/ *" 266 | */ 267 | @property (nonatomic, copy) NSString *fileType; 268 | 269 | /** 270 | * 文件名,(例如图片 imageName.png, 文件名后要跟文件后缀名,否则没法识别,导致类似图片不显示的问题) 271 | * 默认 "um_share_file.txt" 272 | */ 273 | @property (nonatomic, copy) NSString *fileName; 274 | 275 | @end 276 | 277 | 278 | /*! @brief 分享消息中的短信分享对象 279 | * 280 | * @see UMSocialMessageObject 281 | * @discuss UMShareSmsObject只能发送的附件是图片!!!! 282 | * 如果发送其他的文件的话,虽然能在短信界面显示发送的文件,但是会发送不成功 283 | */ 284 | @interface UMShareSmsObject : UMShareObject 285 | 286 | /** 287 | * 接收人 288 | */ 289 | @property (nonatomic, strong) NSArray *recipients; 290 | 291 | /** 292 | * 主题 293 | */ 294 | @property (nonatomic, strong) NSString *subject; 295 | 296 | /** 297 | * 文本内容 298 | */ 299 | @property (nonatomic, copy) NSString *smsContent; 300 | 301 | /** 302 | * 图片 303 | */ 304 | @property (nonatomic, strong) id smsImage;//UIImage对象必填 305 | @property (nonatomic, copy) NSString *imageType;//图片格式必填,必须指定数据格式,如png图片格式应传入@"png" 306 | @property (nonatomic, copy) NSString *imageName;//图片 例如 imageName.png, 文件名后要跟文件后缀名,否则没法识别,导致类似图片不显示的问题) 307 | 308 | 309 | #pragma mark - 以下字段为非图片的属性 310 | /** 311 | * 文件数据(NSData) 312 | * 必填 313 | */ 314 | @property (nonatomic, strong) NSData *smsSendData; 315 | 316 | /** 317 | * 文件格式 318 | * 必填,必须指定数据格式,如png图片格式应传入@"txt" 319 | */ 320 | @property (nonatomic, copy) NSString *fileType; 321 | 322 | /** 323 | * 文件名,(例如图片 fileName.txt, 文件名后要跟文件后缀名,否则没法识别,导致类似图片不显示的问题) 324 | */ 325 | @property (nonatomic, copy) NSString *fileName; 326 | 327 | /** 328 | * 文件地址url(http:// or file:// ...../fileName.txt) 329 | */ 330 | @property (nonatomic, copy) NSString *fileUrl; 331 | 332 | @end 333 | 334 | 335 | /** 336 | * 表情的类 337 | * 表请的缩略图数据请存放在UMShareEmotionObject中 338 | * 注意:emotionData和emotionURL成员不能同时为空,若同时出现则取emotionURL 339 | */ 340 | @interface UMShareEmotionObject : UMShareObject 341 | 342 | /** 343 | * 表情数据,如GIF等 344 | * @note 微信的话大小不能超过10M 345 | */ 346 | @property (nonatomic, strong) NSData *emotionData; 347 | 348 | /** 349 | * @param title 标题 350 | * @param descr 描述 351 | * @param thumImage 缩略图(UIImage或者NSData类型,或者image_url) 352 | * 353 | */ 354 | + (UMShareEmotionObject *)shareObjectWithTitle:(NSString *)title 355 | descr:(NSString *)descr 356 | thumImage:(id)thumImage; 357 | 358 | @end 359 | 360 | 361 | #pragma mark - UMSAppExtendObject 362 | /*! @brief 多媒体消息中包含的App扩展数据对象 363 | * 364 | * 第三方程序向微信终端发送包含UMShareExtendObject的多媒体消息, 365 | * 微信需要处理该消息时,会调用该第三方程序来处理多媒体消息内容。 366 | * @note url,extInfo和fileData不能同时为空 367 | * @see UMShareObject 368 | */ 369 | @interface UMShareExtendObject : UMShareObject 370 | 371 | /** 若第三方程序不存在,微信终端会打开该url所指的App下载地址 372 | * @note 长度不能超过10K 373 | */ 374 | @property (nonatomic, retain) NSString *url; 375 | /** 第三方程序自定义简单数据,微信终端会回传给第三方程序处理 376 | * @note 长度不能超过2K 377 | */ 378 | @property (nonatomic, retain) NSString *extInfo; 379 | /** App文件数据,该数据发送给微信好友,微信好友需要点击后下载数据,微信终端会回传给第三方程序处理 380 | * @note 大小不能超过10M 381 | */ 382 | @property (nonatomic, retain) NSData *fileData; 383 | 384 | @end 385 | 386 | 387 | #pragma mark - UMFileObject 388 | /*! @brief 多媒体消息中包含的文件数据对象 389 | * 390 | * @see UMShareObject 391 | */ 392 | @interface UMShareFileObject : UMShareObject 393 | 394 | /** 文件后缀名 395 | * @note 长度不超过64字节 396 | */ 397 | @property (nonatomic, retain) NSString *fileExtension; 398 | 399 | /** 文件真实数据内容 400 | * @note 大小不能超过10M 401 | */ 402 | @property (nonatomic, retain) NSData *fileData; 403 | 404 | 405 | @end 406 | 407 | 408 | #pragma mark - UMMiniProgramObject 409 | 410 | typedef NS_ENUM(NSUInteger, UShareWXMiniProgramType){ 411 | UShareWXMiniProgramTypeRelease = 0, //**< 正式版 */ 412 | UShareWXMiniProgramTypeTest = 1, //**< 开发版 */ 413 | UShareWXMiniProgramTypePreview = 2, //**< 体验版 */ 414 | }; 415 | 416 | /*! @brief 多媒体消息中包含 分享微信小程序的数据对象 417 | * 418 | * @see UMShareObject 419 | */ 420 | @interface UMShareMiniProgramObject : UMShareObject 421 | 422 | /** 423 | 低版本微信网页链接 424 | */ 425 | @property (nonatomic, strong) NSString *webpageUrl; 426 | 427 | /** 428 | 小程序username 429 | */ 430 | @property (nonatomic, strong) NSString *userName; 431 | 432 | /** 433 | 小程序页面的路径 434 | */ 435 | @property (nonatomic, strong) NSString *path; 436 | 437 | /** 438 | 小程序新版本的预览图 128k 439 | */ 440 | @property (nonatomic, strong) NSData *hdImageData; 441 | 442 | /** 443 | 分享小程序的版本(正式,开发,体验) 444 | 正式版 尾巴正常显示 445 | 开发版 尾巴显示“未发布的小程序·开发版” 446 | 体验版 尾巴显示“未发布的小程序·体验版” 447 | */ 448 | @property (nonatomic, assign) UShareWXMiniProgramType miniProgramType; 449 | 450 | /** 451 | 是否使用带 shareTicket 的转发 452 | */ 453 | @property (nonatomic, assign) BOOL withShareTicket; 454 | 455 | @end 456 | 457 | 458 | -------------------------------------------------------------------------------- /ios/RNUMCommon/UMShare/UMSocialPlatformProvider.h: -------------------------------------------------------------------------------- 1 | // 2 | // UMSocialPlatformProvider.h 3 | // UMSocialSDK 4 | // 5 | // Created by 张军华 on 16/8/4. 6 | // Copyright © 2016年 dongjianxiong. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import "UMSocialPlatformConfig.h" 12 | 13 | @class UMSocialMessageObject; 14 | 15 | /** 16 | * 每个平台的必须实现的协议 17 | */ 18 | @protocol UMSocialPlatformProvider 19 | 20 | @optional 21 | /** 22 | * 当前UMSocialPlatformProvider对应操作的UMSocialPlatformType 23 | * @discuss 当前很多平台对应多个平台类型,出现一对多的关系 24 | * 例如:QQ提供UMSocialPlatformType_Qzone 和 UMSocialPlatformType_QQ,用户点击分享或者认证的时候,需要区分用户分享或者认证的对应的哪个平台 25 | */ 26 | @property(nonatomic,assign)UMSocialPlatformType socialPlatformType; 27 | 28 | /** 29 | * 初始化平台 30 | * 31 | * @param appKey 对应的appkey 32 | * @param appSecret 对应的appSecret 33 | * @param redirectURL 对应的重定向url 34 | * @discuss appSecret和redirectURL如果平台必须要的话就传入,不需要就传入nil 35 | */ 36 | -(void)umSocial_setAppKey:(NSString *)appKey 37 | withAppSecret:(NSString *)appSecret 38 | withRedirectURL:(NSString *)redirectURL; 39 | 40 | /** 41 | * 授权 42 | * 43 | * @param userInfo 用户的授权的自定义数据 44 | * @param completionHandler 授权后的回调 45 | * @discuss userInfo在有些平台可以带入,如果没有就传入nil. 46 | */ 47 | -(void)umSocial_AuthorizeWithUserInfo:(NSDictionary *)userInfo 48 | withCompletionHandler:(UMSocialRequestCompletionHandler)completionHandler; 49 | 50 | /** 51 | * 授权 52 | * 53 | * @param userInfo 用户的授权的自定义数据 54 | * @param completionHandler 授权后的回调 55 | * @parm viewController 分享需要的viewController 56 | * @discuss userInfo在有些平台可以带入,如果没有就传入nil. 57 | * 这个函数用于sms,email等需要传入viewController的平台 58 | */ 59 | -(void)umSocial_AuthorizeWithUserInfo:(NSDictionary *)userInfo 60 | withViewController:(UIViewController*)viewController 61 | withCompletionHandler:(UMSocialRequestCompletionHandler)completionHandler; 62 | 63 | /** 64 | * 分享 65 | * 66 | * @param object 分享的对象数据模型 67 | * @param completionHandler 分享后的回调 68 | */ 69 | -(void)umSocial_ShareWithObject:(UMSocialMessageObject *)object 70 | withCompletionHandler:(UMSocialRequestCompletionHandler)completionHandler; 71 | 72 | /** 73 | * 分享 74 | * 75 | * @param object 分享的对象数据模型 76 | * @param completionHandler 分享后的回调 77 | * @parm viewController 分享需要的viewController 78 | * @dicuss 这个函数用于sms,email等需要传入viewController的平台 79 | */ 80 | -(void)umSocial_ShareWithObject:(UMSocialMessageObject *)object 81 | withViewController:(UIViewController*)viewController 82 | withCompletionHandler:(UMSocialRequestCompletionHandler)completionHandler; 83 | 84 | /** 85 | * 取消授权 86 | * 87 | * @param completionHandler 授权后的回调 88 | * @discuss userInfo在有些平台可以带入,如果没有就传入nil. 89 | */ 90 | -(void)umSocial_cancelAuthWithCompletionHandler:(UMSocialRequestCompletionHandler)completionHandler; 91 | 92 | /** 93 | * 授权成功后获得用户的信息 94 | * 95 | * @param completionHandler 请求的回调 96 | */ 97 | -(void)umSocial_RequestForUserProfileWithCompletionHandler:(UMSocialRequestCompletionHandler)completionHandler; 98 | 99 | 100 | /** 101 | * 获取用户信息 102 | * @param currentViewController 用于弹出类似邮件分享、短信分享等这样的系统页面 103 | * @param completion 回调 104 | */ 105 | - (void)umSocial_RequestForUserProfileWithViewController:(id)currentViewController 106 | completion:(UMSocialRequestCompletionHandler)completion; 107 | 108 | 109 | /** 110 | * 清除平台的数据F 111 | */ 112 | -(void)umSocial_clearCacheData; 113 | 114 | /** 115 | * 获得从sso或者web端回调到本app的回调 116 | * 117 | * @param url 第三方sdk的打开本app的回调的url 118 | * 119 | * @return 是否处理 YES代表处理成功,NO代表不处理 120 | */ 121 | -(BOOL)umSocial_handleOpenURL:(NSURL *)url; 122 | -(BOOL)umSocial_handleOpenURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation; 123 | -(BOOL)umSocial_handleOpenURL:(NSURL *)url options:(NSDictionary*)options; 124 | 125 | 126 | #pragma mark - 平台的特性 127 | /** 128 | * 平台的特性 129 | * 130 | * @return 返回平台特性 131 | * 132 | */ 133 | -(UMSocialPlatformFeature)umSocial_SupportedFeatures; 134 | 135 | /** 136 | * 平台的版本 137 | * 138 | * @return 当前平台sdk的version 139 | */ 140 | -(NSString *)umSocial_PlatformSDKVersion; 141 | 142 | /** 143 | * 检查urlschema 144 | * 145 | */ 146 | -(BOOL)checkUrlSchema; 147 | 148 | 149 | -(BOOL)umSocial_isInstall; 150 | 151 | -(BOOL)umSocial_isSupport; 152 | 153 | 154 | @end 155 | 156 | 157 | -------------------------------------------------------------------------------- /ios/RNUMCommon/UMShare/UMSocialResponse.h: -------------------------------------------------------------------------------- 1 | // 2 | // UMSocialResponse.h 3 | // UMSocialSDK 4 | // 5 | // Created by wangfei on 16/8/12. 6 | // Copyright © 2016年 dongjianxiong. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "UMSocialPlatformConfig.h" 11 | 12 | @interface UMSocialResponse : NSObject 13 | 14 | @property (nonatomic, copy) NSString *uid; 15 | @property (nonatomic, copy) NSString *openid; 16 | @property (nonatomic, copy) NSString *refreshToken; 17 | @property (nonatomic, copy) NSDate *expiration; 18 | @property (nonatomic, copy) NSString *accessToken; 19 | 20 | @property (nonatomic, copy) NSString *unionId; 21 | 22 | 23 | /** 24 | usid 兼容U-Share 4.x/5.x 版本,与4/5版本数值相同 25 | 即,对应微信平台:openId,QQ平台openId,其他平台不变 26 | */ 27 | @property (nonatomic, copy) NSString *usid; 28 | 29 | @property (nonatomic, assign) UMSocialPlatformType platformType; 30 | /** 31 | * 第三方原始数据 32 | */ 33 | @property (nonatomic, strong) id originalResponse; 34 | 35 | /** 36 | 6.5版版本新加入的扩展字段 37 | */ 38 | @property (nonatomic, strong)NSDictionary* extDic;//每个平台特有的字段有可能会加在此处,有可能为nil 39 | 40 | @end 41 | 42 | @interface UMSocialShareResponse : UMSocialResponse 43 | 44 | @property (nonatomic, copy) NSString *message; 45 | 46 | + (UMSocialShareResponse *)shareResponseWithMessage:(NSString *)message; 47 | 48 | @end 49 | 50 | @interface UMSocialAuthResponse : UMSocialResponse 51 | 52 | @end 53 | 54 | @interface UMSocialUserInfoResponse : UMSocialResponse 55 | 56 | /** 57 | 第三方平台昵称 58 | */ 59 | @property (nonatomic, copy) NSString *name; 60 | 61 | /** 62 | 第三方平台头像地址 63 | */ 64 | @property (nonatomic, copy) NSString *iconurl; 65 | 66 | /** 67 | 通用平台性别属性 68 | QQ、微信、微博返回 "男", "女" 69 | Facebook返回 "male", "female" 70 | */ 71 | @property (nonatomic, copy) NSString *unionGender; 72 | 73 | @property (nonatomic, copy) NSString *gender; 74 | 75 | @end 76 | -------------------------------------------------------------------------------- /ios/RNUMCommon/UMShare/UMSocialWarterMarkConfig.h: -------------------------------------------------------------------------------- 1 | // 2 | // UMSocialWarterMarkConfig.h 3 | // testWatermarkImage 4 | // 5 | // Created by 张军华 on 16/12/23. 6 | // Copyright © 2016年 张军华. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import 12 | 13 | @class UMSocialStringWarterMarkConfig; 14 | @class UMSocialImageWarterMarkConfig; 15 | 16 | typedef NS_ENUM(NSInteger, UMSocialWarterMarkPositon) { 17 | UMSocialWarterMarkPositonNone = 0, 18 | 19 | /************************************************************************ 20 | 水印字符串的位置,目前并没有用--start 21 | *************************************************************************/ 22 | UMSocialStringWarterMarkTopLeft = (1 << 0), 23 | UMSocialStringWarterMarkTopRight = (1 << 1), 24 | UMSocialStringWarterMarkBottomLeft = (1 << 2), 25 | UMSocialStringWarterMarkBottomRight = (1 << 3), 26 | /************************************************************************ 27 | 水印字符串的位置,目前并没有用--end 28 | *************************************************************************/ 29 | 30 | //水印图片的位置 31 | UMSocialImageWarterMarkTopLeft = (1 << 4), 32 | UMSocialImageWarterMarkTopRight = (1 << 5), 33 | UMSocialImageWarterMarkBottomLeft = (1 << 6), 34 | UMSocialImageWarterMarkBottomRight = (1 << 7), 35 | 36 | /************************************************************************ 37 | 水印字符串和水印图片的相对位置,目前并没有用(如果图片和字符串都在同一个位置,就需要设置相对位置)--start 38 | *************************************************************************/ 39 | UMSocialImageWarterMarkForwardStringWarterMark = (1 << 8), //图片在字符串前面 40 | UMSocialStringWarterMarkForwardImageWarterMark = (1 << 9),//字符串在图片前面 41 | UMSocialImageWarterMarkAboveStringWarterMark = (1 << 10),//图片在字符串上面 42 | UMSocialStringWarterMarkAboveImageWarterMark = (1 << 11),//字符串在图片上面 43 | /************************************************************************ 44 | 水印字符串和水印图片的相对位置,目前并没有用(如果图片和字符串都在同一个位置,就需要设置相对位置)--end 45 | *************************************************************************/ 46 | }; 47 | 48 | typedef NS_OPTIONS(NSInteger, UMSocialStringAndImageWarterMarkPositon) { 49 | UMSocialStringAndImageWarterMarkPositonNone = 0, 50 | 51 | UMSocialOnlyImageWarterMarkTopLeft = UMSocialImageWarterMarkTopLeft,//水印图片左上 52 | UMSocialOnlyImageWarterMarkTopRight = UMSocialImageWarterMarkTopRight,//水印图片右上 53 | UMSocialOnlyImageWarterMarkBottomLeft = UMSocialImageWarterMarkBottomLeft,//水印图片左下 54 | UMSocialOnlyImageWarterMarkBottomRight = UMSocialImageWarterMarkBottomRight,//水印图片右下 55 | 56 | /************************************************************************ 57 | 以下的枚举变量,目前并没有用--start 58 | *************************************************************************/ 59 | UMSocialStringWarterMarkTopLeftAndImageWarterMarkTopLeft = (UMSocialStringWarterMarkTopLeft | UMSocialImageWarterMarkTopLeft),//水印字符串左上,水印图片左上 60 | UMSocialStringWarterMarkTopLeftAndImageWarterMarkTopRight = (UMSocialStringWarterMarkTopLeft | UMSocialImageWarterMarkTopRight),//水印字符串左上,水印图片右上 61 | UMSocialStringWarterMarkTopLeftAndImageWarterMarkBottomLeft = (UMSocialStringWarterMarkTopLeft | UMSocialImageWarterMarkBottomLeft),//水印字符串左上,水印图片左下 62 | UMSocialStringWarterMarkTopLeftAndImageWarterMarkBottomRight = (UMSocialStringWarterMarkTopLeft | UMSocialImageWarterMarkBottomRight),//水印字符串左上,水印图片右下 63 | 64 | UMSocialStringWarterMarkTopRightAndImageWarterMarkTopLeft = (UMSocialStringWarterMarkTopRight | UMSocialImageWarterMarkTopLeft),//水印字符串右上,水印图片左上 65 | UMSocialStringWarterMarkTopRightAndImageWarterMarkTopRight = (UMSocialStringWarterMarkTopRight | UMSocialImageWarterMarkTopRight),//水印字符串右上,水印图片右上 66 | UMSocialStringWarterMarkTopRightAndImageWarterMarkBottomLeft = (UMSocialStringWarterMarkTopRight | UMSocialImageWarterMarkBottomLeft),//水印字符串右上,水印图片左下 67 | UMSocialStringWarterMarkTopRightAndImageWarterMarkBottomRight = (UMSocialStringWarterMarkTopRight | UMSocialImageWarterMarkBottomRight),//水印字符串右上,水印图片右下 68 | 69 | UMSocialStringWarterMarkBottomLeftAndImageWarterMarkTopLeft = (UMSocialStringWarterMarkBottomLeft | UMSocialImageWarterMarkTopLeft),//水印字符串左下,水印图片左上 70 | UMSocialStringWarterMarkBottomLeftAndImageWarterMarkTopRight = (UMSocialStringWarterMarkBottomLeft | UMSocialImageWarterMarkTopRight),//水印字符串左下,水印图片右上 71 | UMSocialStringWarterMarkBottomLeftAndImageWarterMarkBottomLeft = (UMSocialStringWarterMarkBottomLeft | UMSocialImageWarterMarkBottomLeft),//水印字符串左下,水印图片左下 72 | UMSocialStringWarterMarkBottomLeftAndImageWarterMarkBottomRight = (UMSocialStringWarterMarkBottomLeft | UMSocialImageWarterMarkBottomRight),//水印字符串左下,水印图片右下 73 | 74 | UMSocialStringWarterMarkBottomRightAndImageWarterMarkTopLeft = (UMSocialStringWarterMarkBottomRight | UMSocialImageWarterMarkTopLeft),//水印字符串右下,水印图片左上 75 | UMSocialStringWarterMarkBottomRightAndImageWarterMarkTopRight = (UMSocialStringWarterMarkBottomRight | UMSocialImageWarterMarkTopRight),//水印字符串右下,水印图片右上 76 | UMSocialStringWarterMarkBottomRightAndImageWarterMarkBottomLeft = (UMSocialStringWarterMarkBottomRight | UMSocialImageWarterMarkBottomLeft),//水印字符串右下,水印图片左下 77 | UMSocialStringWarterMarkBottomRightAndImageWarterMarkBottomRight = (UMSocialStringWarterMarkBottomRight | UMSocialImageWarterMarkBottomRight),//水印字符串右下,水印图片右下 78 | 79 | /************************************************************************ 80 | 以下的枚举变量,目前并没有用---end 81 | *************************************************************************/ 82 | }; 83 | 84 | extern UMSocialWarterMarkPositon getStringWarterMarkPostion(UMSocialStringAndImageWarterMarkPositon stringAndImageWarterMarkPositon); 85 | extern UMSocialWarterMarkPositon getImageWarterMarkPostion(UMSocialStringAndImageWarterMarkPositon stringAndImageWarterMarkPositon); 86 | extern UMSocialWarterMarkPositon getRelatedWarterMarkPostion(UMSocialStringAndImageWarterMarkPositon stringAndImageWarterMarkPositon); 87 | 88 | 89 | /** 90 | * 水印配置类 91 | * 用户可以设置水印的配置类,目前只是提供图片水印 92 | * 93 | * method1: 94 | * 用户可以通过默认的配置类来配置水印 95 | * 代码如下: 96 | UMSocialWarterMarkConfig* warterMarkConfig = [UMSocialWarterMarkConfig defaultWarterMarkConfig]; 97 | * 98 | * method2: 99 | * 用户可以通过创建自己的配置类来配置水印 100 | * 代码如下: 101 | //创建UMSocialImageWarterMarkConfig 102 | UMSocialImageWarterMarkConfig* imageWarterMarkConfig = [[UMSocialImageWarterMarkConfig alloc] init]; 103 | //配置imageWarterMarkConfig的参数 104 | //...TODO 105 | //创建UMSocialWarterMarkConfig 106 | UMSocialWarterMarkConfig* warterMarkConfig = [[UMSocialWarterMarkConfig alloc] init]; 107 | //配置warterMarkConfig的参数 108 | //...TODO 109 | //设置配置类 110 | [warterMarkConfig setUserDefinedImageWarterMarkConfig:imageWarterMarkConfig]; 111 | * 112 | * 113 | */ 114 | @interface UMSocialWarterMarkConfig : NSObject 115 | 116 | /** 117 | * 默认配置类 118 | * 119 | * @return 默认配置类 120 | */ 121 | +(UMSocialWarterMarkConfig*)defaultWarterMarkConfig; 122 | 123 | 124 | @property(nonatomic,readonly,strong)UMSocialStringWarterMarkConfig* stringWarterMarkConfig;//字符串配置类对象 125 | @property(nonatomic,readonly,strong)UMSocialImageWarterMarkConfig* imageWarterMarkConfig;//图片配置类对象 126 | 127 | /** 128 | * 字符串和图片的位置 129 | * 默认是defaultWarterMarkConfig的配置为文字和图片右下角,图片在前文字在后 130 | */ 131 | @property(nonatomic,readwrite,assign)UMSocialStringAndImageWarterMarkPositon stringAndImageWarterMarkPositon;//字符串和图片的位置 132 | @property(nonatomic,readwrite,assign)CGFloat spaceBetweenStringWarterMarkAndImageWarterMark;//字符水印和图片水印的间距 133 | 134 | /** 135 | * 设置用户自定义的配置类 136 | * 137 | * @param imageWarterMarkConfig 图片配置类对象 138 | */ 139 | -(void)setUserDefinedImageWarterMarkConfig:(UMSocialImageWarterMarkConfig*)imageWarterMarkConfig; 140 | 141 | @end 142 | 143 | 144 | /** 145 | * 字符水印配置类 146 | * 目前此配置类没有使用 147 | */ 148 | @interface UMSocialStringWarterMarkConfig : NSObject 149 | 150 | /** 151 | * 默认配置类 152 | * 153 | * @return 默认配置类 154 | */ 155 | +(UMSocialStringWarterMarkConfig*)defaultStringWarterMarkConfig; 156 | 157 | //检查参数是否有效 158 | -(BOOL)checkValid; 159 | 160 | @property(nonatomic,readwrite,strong)NSAttributedString* warterMarkAttributedString;//水印字符串 161 | @property(nonatomic,readwrite,assign)NSUInteger warterMarkStringLimit;//水印字符串的字数限制 162 | @property(nonatomic,readwrite,strong)UIColor* warterMarkStringColor;//水印字符串的颜色(要想保证色值半透明,可以创建半透明的颜色对象) 163 | @property(nonatomic,readwrite,strong)UIFont* warterMarkStringFont;//水印字符串的字体 164 | 165 | /** 166 | * 靠近水平边的边距 167 | * 与UMSocialWarterMarkPositon的停靠位置有关, 168 | 如:为UMSocialStringWarterMarkBottomRight时,paddingToHorizontalParentBorder代表与父窗口的右边间隙. 169 | 如:UMSocialStringWarterMarkTopLeft时,paddingToHorizontalParentBorder代表与父窗口的左边间隙. 170 | */ 171 | @property(nonatomic,readwrite,assign)CGFloat paddingToHorizontalParentBorder;//靠近水平边的边距 172 | 173 | /** 174 | * 靠近垂直边的边距 175 | * 与UMSocialWarterMarkPositon的停靠位置有关, 176 | 如:为UMSocialStringWarterMarkBottomRight时,paddingToHorizontalParentBorder代表与父窗口的下边的间隙. 177 | 如:UMSocialStringWarterMarkTopLeft时,paddingToHorizontalParentBorder代表与父窗口的上边间隙. 178 | */ 179 | @property(nonatomic,readwrite,assign)CGFloat paddingToVerticalParentBorder;//靠近垂直边的边距 180 | 181 | @property(nonatomic,readonly,assign)CGAffineTransform warterMarkStringTransform;//水印字符串的矩阵 182 | 183 | @end 184 | 185 | /** 186 | * 图片配置类 187 | */ 188 | @interface UMSocialImageWarterMarkConfig : NSObject 189 | 190 | /** 191 | * 默认配置类 192 | * 193 | * @return 默认配置类 194 | */ 195 | +(UMSocialImageWarterMarkConfig*)defaultImageWarterMarkConfig; 196 | 197 | //检查参数是否有效 198 | -(BOOL)checkValid; 199 | 200 | @property(nonatomic,readwrite,strong)UIImage* warterMarkImage;//水印图片 201 | @property(nonatomic,readwrite,assign)CGFloat warterMarkImageScale;//水印图片相对父图片的缩放因素(0-1之间) 202 | @property(nonatomic,readwrite,assign)CGFloat warterMarkImageAlpha;//水印图片的Alpha混合值 203 | 204 | /** 205 | * 靠近水平边的边距 206 | * 与UMSocialWarterMarkPositon的停靠位置有关, 207 | 如:为UMSocialImageWarterMarkBottomRight时,paddingToHorizontalParentBorder代表与父窗口的右边间隙. 208 | 如:UMSocialImageWarterMarkTopLeft时,paddingToHorizontalParentBorder代表与父窗口的左边间隙. 209 | */ 210 | @property(nonatomic,readwrite,assign)CGFloat paddingToHorizontalParentBorder;//靠近水平边的边距 211 | 212 | /** 213 | * 靠近垂直边的边距 214 | * 与UMSocialWarterMarkPositon的停靠位置有关, 215 | 如:为UMSocialImageWarterMarkBottomRight时,paddingToHorizontalParentBorder代表与父窗口的下边间隙. 216 | 如:UMSocialImageWarterMarkTopLeft时,paddingToHorizontalParentBorder代表与父窗口的上边间隙. 217 | */ 218 | @property(nonatomic,readwrite,assign)CGFloat paddingToVerticalParentBorder;//靠近垂直边的边距 219 | 220 | @property(nonatomic,readonly,assign)CGAffineTransform warterMarkImageTransform;//水印图片的矩阵 221 | 222 | @end 223 | -------------------------------------------------------------------------------- /ios/RNUMCommon/UMShare/UMSociallogMacros.h: -------------------------------------------------------------------------------- 1 | // 2 | // UMSociallogMacros.h 3 | // UMSocialCore 4 | // 5 | // Created by 张军华 on 16/9/7. 6 | // Copyright © 2016年 张军华. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "UMCommonLogMacros.h" 11 | 12 | 13 | //简易函数类似于系统的NSLog函数,线程安全 14 | #define UMSocialLogError UMShareLogError 15 | #define UMSocialLogWarn UMShareLogWarn 16 | #define UMSocialLogInfo UMShareLogInfo 17 | #define UMSocialLogDebug UMShareLogDebug 18 | #define UMSocialLogVerbose UMShareLogVerbose 19 | 20 | 21 | //日志国际化的相关的函数和宏 22 | FOUNDATION_EXPORT NSString* UMSocialLogWithLocalizedKey(NSString* key); 23 | #define UMSocialLogLocalizedString(key) UMSocialLogWithLocalizedKey(key) 24 | 25 | 26 | -------------------------------------------------------------------------------- /ios/RNUMCommon/UMShareModule.h: -------------------------------------------------------------------------------- 1 | // 2 | // ShareModule.h 3 | // UMComponent 4 | // 5 | // Created by wyq.Cloudayc on 11/09/2017. 6 | // Copyright © 2017 Facebook. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import 12 | @interface UMShareModule : RCTEventEmitter 13 | +(BOOL)handleOpenURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation; 14 | +(BOOL)handleOpenURL:(NSURL *)url; 15 | @end 16 | 17 | -------------------------------------------------------------------------------- /ios/RNUMCommon/pushListener.h: -------------------------------------------------------------------------------- 1 | // 2 | // pushListener.h 3 | // reactnativeUMCommon 4 | // 5 | // Created by 马拉古 on 2018/6/13. 6 | // Copyright © 2018年 shanghaiDouke.com. All rights reserved. 7 | // 8 | 9 | //#import "RCTEventEmitter.h" 10 | #import 11 | #import 12 | @interface pushListener : RCTEventEmitter 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /ios/RNUMCommon/pushListener.m: -------------------------------------------------------------------------------- 1 | // 2 | // pushListener.m 3 | // reactnativeUMCommon 4 | // 5 | // Created by 马拉古 on 2018/6/13. 6 | // Copyright © 2018年 shanghaiDouke.com. All rights reserved. 7 | // 8 | 9 | #import "pushListener.h" 10 | static NSString * const recivePushNoti = @"recivePushNoti"; 11 | static NSString * const openPushNoti = @"openPushNoti"; 12 | static NSString * const DidReceiveMessage = @"didReceiveMessage"; 13 | static NSString * const DidOpenMessage = @"didOpenMessage"; 14 | @implementation pushListener 15 | { 16 | bool _hasListeners; 17 | } 18 | RCT_EXPORT_MODULE(); 19 | //rn代理 20 | - (NSArray *)supportedEvents 21 | { 22 | return @[DidReceiveMessage,DidOpenMessage]; 23 | } 24 | 25 | -(instancetype)init{ 26 | self = [super init]; 27 | if (self) { 28 | [[NSNotificationCenter defaultCenter] addObserver:self 29 | selector:@selector(didReceivNoti:) 30 | name:recivePushNoti 31 | object:nil]; 32 | [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(openMsg:) name:openPushNoti object:nil]; 33 | } 34 | return self; 35 | } 36 | 37 | - (void)startObserving 38 | { 39 | _hasListeners = YES; 40 | } 41 | - (void)stopObserving 42 | { 43 | 44 | _hasListeners = NO; 45 | } 46 | 47 | -(void)didReceivNoti:(NSNotification *)notification{ 48 | 49 | if (_hasListeners) { 50 | [self sendEventWithName:DidReceiveMessage 51 | body:notification.userInfo]; 52 | } 53 | } 54 | 55 | -(void)openMsg:(NSNotification *)notification{ 56 | 57 | if (_hasListeners) { 58 | [self sendEventWithName:DidOpenMessage body:notification.userInfo]; 59 | } 60 | } 61 | 62 | @end 63 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-native-dk-umeng", 3 | "version": "1.0.1", 4 | "description": "react native 友盟分享、推送、统计", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "Magic", 10 | "license": "ISC", 11 | "repository": { 12 | "type": "git", 13 | "url": "git+https://github.com/yolinsoft/react-native-dk-umeng.git" 14 | }, 15 | "bugs": { 16 | "url": "https://github.com/yolinsoft/react-native-dk-umeng/issues" 17 | }, 18 | "homepage": "https://github.com/yolinsoft/react-native-dk-umeng#readme" 19 | } --------------------------------------------------------------------------------