【问题标题】:Xtify + Worklight 6.1 integration in android environmentandroid环境中的Xtify + Worklight 6.1集成
【发布时间】:2014-06-04 16:18:00
【问题描述】:

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

WL混合应用的原生代码中添加了使用xtify的逻辑如下:

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 项目的构建路径中。

谢谢,

【问题讨论】:

    标签: android push-notification ibm-mobilefirst xtify


    【解决方案1】:

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

    这是 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>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-03-31
      • 1970-01-01
      • 2015-01-18
      • 2013-12-27
      • 1970-01-01
      • 2014-11-06
      • 2017-03-07
      • 1970-01-01
      相关资源
      最近更新 更多