0

我们一直致力于在 Worklight 和 xtify 之间进行推送通知的集成。我们为 xtify sdk 使用版本 2.3.2,因为最新版本 (2.4.2) 使应用程序失败,因为找不到类异常。

使用 xtify 的逻辑已添加到 WL 混合应用程序的本机代码中,如下所示:

public class XtifyWL extends WLDroidGap {
    public static final String XTIFY_APP_KEY = "xxxxxxxx-xxxxx-xxxx-xxxxx-xxxxxxxxx";
    public static final String PROJECT_NUM = "xxxxxxxxxxxx"; // This is the Google Project Number


    @Override
    protected void onStart() {
        // TODO Auto-generated method stub
        super.onStart();
        XtifySDK.start(getApplicationContext(), XTIFY_APP_KEY, PROJECT_NUM);
    }

我们正在接收推送通知,但它们是重复的。当您尝试打开 Worklight 时,我们收到了一条失败的通知,另外还有一条是关于正常工作的本机应用程序的通知。

我们该如何解决?

关于 SDK 2.4.2.2 的问题

SDK 2.4.2.2 的例外是:

FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to get provider com.xtify.sdk.db.Provider: java.lang.ClassNotFoundException: com.xtify.sdk.db.Provider
at android.app.ActivityThread.installProvider(ActivityThread.java:4609)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4236)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4178)
at android.app.ActivityThread.access$1400(ActivityThread.java:134)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4867)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1007)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:774)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: com.xtify.sdk.db.Provider
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
at android.app.ActivityThread.installProvider(ActivityThread.java:4594)
... 12 more

我们看到该类的唯一地方是 AndroidManifest.xml

<provider android:name="com.xtify.sdk.db.Provider" android:authorities="com.XtifyApp.XTIFY_PROVIDER" android:exported="false" />

如果我们注释该行,则下次使用 SDK 的任何类时都会失败。我们已将 sdk .jar 文件添加到 android 项目的 libs 文件夹和 android 项目的构建路径中。

谢谢,

4

1 回答 1

0

我们找到了为什么当我们发送推送通知时,我们看到它们重复(顶部有两个通知图标)。

这是 AndroidManifest.xml 中的一个错误,我们添加了所有 Xtify GCM 配置,我们还留下了 worklight GCM 配置,因此我们在其中注册了两个接收器。

但是当我们尝试使用最新的 Xtify SDK 时,仍然存在“java.lang.ClassNotFoundException”的问题。虽然至少接收简单的通知似乎适用于 SDK 2.3.2。

这是正确的 AndroidManifest.xml:

<?xml version="1.0" encoding="UTF-8"?>

<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.XtifyApp" android:versionCode="1" android:versionName="1.0">  
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="18"/>  
<supports-screens android:smallScreens="false" android:normalScreens="true" android:largeScreens="false"/>  
<uses-permission android:name="android.permission.INTERNET"/>  
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>  
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>  
<!-- Push permissions -->  
<permission android:name="com.XtifyApp.permission.C2D_MESSAGE" android:protectionLevel="signature"/>  
<uses-permission android:name="com.XtifyApp.permission.C2D_MESSAGE"/>  
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/>  
<uses-permission android:name="android.permission.WAKE_LOCK"/>  
<uses-permission android:name="android.permission.GET_ACCOUNTS"/>  
<uses-permission android:name="android.permission.USE_CREDENTIALS"/>  
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> 

<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />


<application android:label="@string/app_name" android:debuggable="true" android:icon="@drawable/icon"> 
    <activity android:name=".XtifyApp" android:label="@string/app_name" android:configChanges="orientation|keyboardHidden|screenSize" android:launchMode="singleTask"> 
        <intent-filter> 
            <action android:name="android.intent.action.MAIN"/>  
            <category android:name="android.intent.category.LAUNCHER"/> 
        </intent-filter>  
        <intent-filter> 
            <action android:name="com.XtifyApp.XtifyApp.NOTIFICATION"/>  
            <category android:name="android.intent.category.DEFAULT"/> 
        </intent-filter> 
    </activity>  

    <activity android:name="com.worklight.common.WLPreferences" android:label="Worklight Settings"></activity>

    <!-- Start XTIFY -->


    <provider android:name="com.xtify.sdk.db.Provider" android:authorities="com.XtifyApp.XTIFY_PROVIDER" android:exported="false" />

    <receiver android:name=".XtifyNotifier" >
        <intent-filter>
            <action android:name="com.xtify.sdk.NOTIFIER" />
        </intent-filter>
    </receiver>

    <receiver android:name="com.xtify.sdk.c2dm.C2DMBroadcastReceiver" >
        <intent-filter android:permission="com.google.android.c2dm.permission.SEND" >
            <action android:name="com.google.android.c2dm.intent.RECEIVE" />
            <category android:name="com.XtifyApp" />
        </intent-filter>
        <intent-filter android:permission="com.google.android.c2dm.permission.SEND" >
            <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
            <category android:name="com.XtifyApp" />
        </intent-filter>
    </receiver>

    <receiver android:name="com.xtify.sdk.NotifActionReceiver" />
    <receiver android:name="com.xtify.sdk.wi.AlarmReceiver" >
        <intent-filter>
            <action android:name="android.intent.action.BOOT_COMPLETED" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.TIMEZONE_CHANGED" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.PACKAGE_REPLACED" />
            <data android:scheme="package" />
        </intent-filter>
    </receiver>

    <service android:name="com.xtify.sdk.location.LocationUpdateService" />
    <service android:name="com.xtify.sdk.c2dm.C2DMIntentService" />
    <service android:name="com.xtify.sdk.alarm.MetricsIntentService" />
    <service android:name="com.xtify.sdk.alarm.TagIntentService" />
    <service android:name="com.xtify.sdk.alarm.RegistrationIntentService" />
    <service android:name="com.xtify.sdk.alarm.LocationIntentService" />

    <!-- END XTIFY -->


   <!--  Start Worklight GCM configuration -->
   <!--  
    <service android:name=".GCMIntentService"/>  
    <service android:name=".ForegroundService"/>  

    <receiver android:name="com.google.android.gcm.GCMBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND">             
        <intent-filter> 
            <action android:name="com.google.android.c2dm.intent.RECEIVE"/>  
            <category android:name="com.XtifyApp"/> 
        </intent-filter>  
        <intent-filter> 
            <action android:name="com.google.android.c2dm.intent.REGISTRATION"/>  
            <category android:name="com.XtifyApp"/> 
        </intent-filter> 
    </receiver> 
    -->
    <!--  END Worklight GCM configuration -->

</application> 
</manifest>
于 2014-06-04T23:42:54.457 回答