sunlu / cordova-plugin-xgpush

腾讯信鸽推送服务:http://xg.qq.com/
MIT License
31 stars 32 forks source link

最新的sdk,安卓没有跑通 #12

Open galikaixin opened 7 years ago

galikaixin commented 7 years ago

D/XGPushPlugin: exec : action = addListener, callbackId = XGPush132255936 D/XGPushPlugin: addListener : callbackId=XGPush132255936 D/XGPushPlugin: exec : action = registerPush, callbackId = XGPush132255937 D/XGPushPlugin: > register private:null E/ActivityThread: Failed to find provider info for io.cordova.hellocordova.TPUSH_PROVIDER E/ActivityThread: Failed to find provider info for io.cordova.hellocordova.TPUSH_PROVIDER I/TpnsSecurity: JNI_OnLoad D/CordovaWebViewImpl: onPageFinished(file:///android_asset/www/index.html) E/ActivityThread: Failed to find provider info for io.cordova.hellocordova.TPUSH_PROVIDER I/XINGE: [XGOtherPush] Reservert info: use normal xg token register E/ActivityThread: Failed to find provider info for io.cordova.hellocordova.TPUSH_PROVIDER D/SystemWebChromeClient: file:///android_asset/www/cordova.js: Line 1223 : deviceready has not fired after 5 seconds. I/chromium: [INFO:CONSOLE(1223)] "deviceready has not fired after 5 seconds.", source: file:///android_asset/www/cordova.js (1223) D/SystemWebChromeClient: file:///android_asset/www/cordova.js: Line 1216 : Channel not fired: onCordovaXGPushReady I/chromium: [INFO:CONSOLE(1216)] "Channel not fired: onCordovaXGPushReady", source: file:///android_asset/www/cordova.js (1216)

测试代码: onDeviceReady: function() {

    xgpush.enableDebug(true,function(event){
        console.log(event)
    },function(event){
        console.log(event)
    });

    xgpush.on("register", function (data) {
        console.log("register:", data);
    });

    xgpush.on("click", function (data) {
        alert("click:" + JSON.stringify(data));
    });

    xgpush.getLaunchInfo(function (data) {
        alert("getLaunchInfo:" + JSON.stringify(data));
    }); 

    this.receivedEvent('deviceready');
},

有什么思路吗?

sunlu commented 7 years ago

看看:http://blog.csdn.net/ling369523246/article/details/52187570

galikaixin commented 7 years ago

主要问题是:Failed to find provider info for io.cordova.hellocordova.TPUSH_PROVIDER 我根据xg的官网文档,重新配置了plugin.xml,现在可以跑了。貌似最新版的3.1的sdk需要调整的配置挺多的。http://developer.qq.com/wiki/xg/Android接入/Android%20SDK快速接入/Android%20SDK快速接入.html

galikaixin commented 7 years ago

我帖一下我改动过的plugin.xml,测试的结果是ok的。主要是新增了mid-core-sdk-3.7.2.jar

<?xml version="1.0" encoding="utf-8"?>
<plugin xmlns:android="http://schemas.android.com/apk/res/android" id="cordova-plugin-xgpush" version="0.1.0">
  <name>cordova-plugin-xgpush</name>
  <description>Tencent XGPush Plugin</description>
  <license>MIT</license>
  <author>sunlu</author>
  <keywords>cordova, push, chinese</keywords>
  <repo>https://github.com/sunlu/cordova-plugin-xgpush.git</repo>
  <issue>https://github.com/sunlu/cordova-plugin-xgpush/issues</issue>

  <preference name="ACCESS_ID" />
  <preference name="ACCESS_KEY" />
  <preference name="IOS_ACCESS_ID" />
  <preference name="IOS_ACCESS_KEY" />

  <js-module name="xgpush" src="www/xgpush.js">
    <clobbers target="xgpush" />
  </js-module>

  <!-- android -->
  <platform name="android">
    <config-file target="res/xml/config.xml" parent="/*">
      <feature name="XGPush">
        <param name="android-package" value="net.sunlu.xgpush.XGPushPlugin" />
      </feature>
    </config-file>
    <config-file target="AndroidManifest.xml" parent="/manifest">
      <uses-permission android:name="android.permission.INTERNET" />
      <uses-permission android:name="android.permission.READ_PHONE_STATE" />
      <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
      <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
      <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
      <uses-permission android:name="android.permission.RESTART_PACKAGES" />
      <uses-permission android:name="android.permission.BROADCAST_STICKY" />
      <uses-permission android:name="android.permission.WRITE_SETTINGS" />
      <uses-permission android:name="android.permission.RECEIVE_USER_PRESENT" />
      <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
      <uses-permission android:name="android.permission.WAKE_LOCK" />
      <uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES" />
      <uses-permission android:name="android.permission.GET_TASKS" />
      <uses-permission android:name="android.permission.READ_LOGS" />
      <uses-permission android:name="android.permission.VIBRATE" />
    </config-file>
    <config-file target="AndroidManifest.xml" parent="/manifest/application">
      <!-- 【必须】 信鸽receiver广播接收 -->
      <receiver android:name="com.tencent.android.tpush.XGPushReceiver" android:process=":xg_service_v3">
        <intent-filter android:priority="0x7fffffff">
          <action android:name="com.tencent.android.tpush.action.SDK" />
          <action android:name="com.tencent.android.tpush.action.INTERNAL_PUSH_MESSAGE" />
          <action android:name="android.intent.action.USER_PRESENT" />
          <action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
        </intent-filter>
      </receiver>
       <!-- 【必须】 (2.30及以上版新增)展示通知的activity -->
      <activity android:name="com.tencent.android.tpush.XGPushActivity" android:theme="@android:style/Theme.Translucent" android:exported="false">
        <intent-filter>
          <action android:name="android.intent.action" />
        </intent-filter>
      </activity>
      <!-- 【必须】 信鸽service -->
      <service android:name="com.tencent.android.tpush.service.XGPushServiceV3" android:exported="true" android:persistent="true" android:process=":xg_service_v3" />
      <!-- 【必须】 增强xg_service存活率  -->
      <service android:name="com.tencent.android.tpush.service.XGDaemonService" android:process=":xg_service_v3">
        <intent-filter>
          <action android:name="$PACKAGE_NAME.PUSH_ACTION" />
        </intent-filter>
      </service>
      <!-- 【必须】 通知service,其中android:name部分要改为当前包名 -->
      <service android:name="com.tencent.android.tpush.rpc.XGRemoteService" android:exported="true" >
          <intent-filter>
                <!-- 【必须】 请修改为当前APP名包.PUSH_ACTION,如demo的包名为:com.qq.xgdemo -->
              <action android:name="io.cordova.hellocordova.PUSH_ACTION" />
          </intent-filter>
      </service>
      <!-- 【必须】 【注意】authorities修改为 包名.AUTH_XGPUSH, 如demo的包名为:com.qq.xgdemo-->
      <provider android:name="com.tencent.android.tpush.XGPushProvider" android:authorities="io.cordova.hellocordova.AUTH_XGPUSH" android:exported="true" />       
       <!-- 【必须】 【注意】authorities修改为 包名.TPUSH_PROVIDER, 如demo的包名为:com.qq.xgdemo-->
      <provider android:name="com.tencent.android.tpush.SettingsContentProvider" android:authorities="io.cordova.hellocordova.TPUSH_PROVIDER" android:exported="false" />
       <!-- 【必须】 【注意】authorities修改为 包名.TENCENT.MID.V3, 如demo的包名为:com.qq.xgdemo-->
      <provider android:name="com.tencent.mid.api.MidProvider" android:authorities="io.cordova.hellocordova.TENCENT.MID.V3" android:exported="true" />
      <meta-data android:name="XG_V2_ACCESS_ID" android:value="$ACCESS_ID"></meta-data>
      <meta-data android:name="XG_V2_ACCESS_KEY" android:value="$ACCESS_KEY"></meta-data>
    </config-file>
    <source-file src="src/android/XGPushPlugin.java" target-dir="src/net/sunlu/xgpush" />
    <source-file src="src/android/XGPushReceiver.java" target-dir="src/net/sunlu/xgpush" />
    <source-file src="src/android/XGPushCallback.java" target-dir="src/net/sunlu/xgpush" />
    <!-- Tencent XGPush SDK  -->
    <source-file src="sdk/android/libs/android-support-v4.jar" target-dir="libs" />
    <source-file src="sdk/android/libs/jg_filter_sdk_1.1.jar" target-dir="libs" />
    <source-file src="sdk/android/libs/Xg_sdk_v3.1_20170417_0946.jar" target-dir="libs" />
    <source-file src="sdk/android/libs/wup-1.0.0.E-SNAPSHOT.jar" target-dir="libs" />
    <source-file src="sdk/android/libs/mid-core-sdk-3.7.2.jar" target-dir="libs" />

    <source-file src="sdk/android/Other-Platform-SO/armeabi/libxguardian.so" target-dir="libs/armeabi" />
    <source-file src="sdk/android/Other-Platform-SO/armeabi/libtpnsSecurity.so" target-dir="libs/armeabi" />
    <source-file src="sdk/android/Other-Platform-SO/armeabi-v7a/libtpnsSecurity.so" target-dir="libs/armeabi-v7a" />
    <source-file src="sdk/android/Other-Platform-SO/armeabi-v7a/libxguardian.so" target-dir="libs/armeabi-v7a" />
  </platform>
  <!-- ios -->
  <platform name="ios">
    <config-file target="config.xml" parent="/*">
      <feature name="XGPush">
        <param name="ios-package" value="CDVXGPushPlugin" />
        <param name="onload" value="true" />
      </feature>
    </config-file>
    <config-file target="*-Info.plist" parent="XGPushMeta">
      <dict>
        <key>AccessID</key>
        <integer>$IOS_ACCESS_ID</integer>
        <key>AccessKey</key>
        <string>$IOS_ACCESS_KEY</string>
      </dict>
    </config-file>
    <!-- Tencent XGPush SDK -->
    <header-file src="sdk/ios/XGPush.h" />
    <header-file src="sdk/ios/XGSetting.h" />
    <source-file src="sdk/ios/libXG-SDK.a" framework="true" />
    <!-- Cordova Plugin -->
    <header-file src="src/ios/AppDelegate+CDVXGPush.h" />
    <source-file src="src/ios/AppDelegate+CDVXGPush.m" />
    <header-file src="src/ios/CDVXGPushPlugin.h" />
    <source-file src="src/ios/CDVXGPushPlugin.m" />
    <!-- Dependencies -->
    <framework src="libz.dylib" />
    <framework src="libsqlite3.dylib" />
    <framework src="CFNetwork.framework" />
    <framework src="SystemConfiguration.framework" />
    <framework src="CoreTelephony.framework" />
    <framework src="Security.framework" />
  </platform>
</plugin>