2015-04-28 29 views
0

使用基於適配器的身份驗證登錄後,我的任務活動1)訂閱2)取消訂閱上有兩個按鈕。onReadyToSubscribe()永遠不會在本地Android上調用

使用基於適配器的身份驗證登錄工作正常。

但是,onReadyToSubscribe()永遠不會被調用,並且在MobileFirst Operations Console上也沒有看到任何註冊的設備。我也嘗試創建一個挑戰處理程序,但仍然沒有運氣。

TaskActivity

private void IBMPushNotificationRegisterEvent(){ 

    client = WLClient.createInstance(this); 
    push = client.getPush(); 

    PushListener listener = new PushListener(PushListener.MODE_CONNECT,this); 

    push.setOnReadyToSubscribeListener(listener); 
    client.connect(listener); 
} 



private void SubscribeNotification(){ 
    client = WLClient.createInstance(this); 
    client.getPush().subscribe("myAndroid",new WLPushOptions(), new PushListener(PushListener.MODE_SUBSCRIBE,this)); 
} 

private void UnSubscribeNotification(){ 
    client = WLClient.createInstance(this); 
    client.getPush().unsubscribe("myAndroid", new PushListener(PushListener.MODE_UNSUBSCRIBE,this)); 
} 

推監聽

public class PushListener implements WLOnReadyToSubscribeListener,WLResponseListener,WLEventSourceListener { 

    public static final int MODE_CONNECT = 0; 
    public static final int MODE_SUBSCRIBE = 1; 
    public static final int MODE_UNSUBSCRIBE =2; 

    private int mode ; 
    private Context currentContext; 

    public PushListener(int mode,Context ctx){ 
     this.mode = mode; 
     currentContext = ctx; 
    } 

    @Override 
    public void onReadyToSubscribe() { 

     WLClient.getInstance().getPush().registerEventSourceCallback("myAndroid", "TaskAdapter","PushEventSource", this); 

    } 

    @Override 
    public void onReceive(String arg0, String arg1) { 

    } 

    @Override 
    public void onSuccess(WLResponse wlResponse) { 

     switch (mode){ 
      case MODE_CONNECT: 
       // connect =true ; 
       break; 

      case MODE_SUBSCRIBE: 
       TextView tt = (TextView) (((Activity)currentContext).findViewById(R.id.tv_statusMsg)); 
       tt.setText("Subscribed"); 
       break; 

      case MODE_UNSUBSCRIBE: 
       // unsubscribe = true; 
       break; 

     } 
    } 

    @Override 
    public void onFailure(WLFailResponse wlFailResponse) { 
     switch (mode){ 
      case MODE_CONNECT: 
       // connect =false ; 
       break; 

      case MODE_SUBSCRIBE: 
       // subscribe = false; 
       break; 

      case MODE_UNSUBSCRIBE: 
       // unsubscribe = false; 
       break; 

     } 
    } 
} 

任務適配器

WL.Server.createEventSource({ 
    name: 'PushEventSource', 
    onDeviceSubscribe: 'deviceSubscribeFunc', 
    onDeviceUnsubscribe: 'deviceUnsubscribeFunc', 
    securityTest:'PushApplication-mobile-securityTest' 


}); 

function deviceSubscribeFunc(userSubscription, deviceSubscription){ 
    WL.Logger.debug(">> deviceSubscribeFunc"); 
} 

function deviceUnsubscribeFunc(userSubscription, deviceSubscription){ 
    WL.Logger.debug(">> deviceUnsubscribeFunc"); 
} 



function submitNotification(userId, notificationText){ 

    var userSubscription = WL.Server.getUserNotificationSubscription('PushAdapter.PushEventSource', userId); 

    if (userSubscription==null){ 
     return { result: "No subscription found for user :: " + userId }; 
    } 

    var badgeDigit = 1; 

    var notification = WL.Server.createDefaultNotification(notificationText, badgeDigit, {custom:"data"}); 



    notification.MPNS.raw = { 
     payload : {payload : "You have a meeting in 5 minutes"} 
    }; 

    WL.Logger.debug("submitNotification >> userId :: " + userId + ", text :: " + notificationText); 

    WL.Server.notifyAllDevices(userSubscription, notification); 

    return { 
     result: "Notification sent to user :: " + userId 
    }; 
} 


function onAuthRequired(headers, errorMessage){ 
    errorMessage = errorMessage ? errorMessage : null; 
    WL.Logger.debug("my test"); 
    return { 
     authRequired: true, 
     errorMessage: errorMessage 
    }; 
} 

function submitAuthentication(username, password){ 
    // if (username==="user" && password === "user"){ 

     var userIdentity = { 
       userId: username, 
       displayName: username, 
       attributes: { 
        foo: "bar" 
       } 
     }; 

     WL.Server.setActiveUser("SingleStepAuthRealm", userIdentity); 

     return { 
      authRequired: false, 
      user :userIdentity 
     }; 
    // } 

    // return onAuthRequired(null, "Invalid login credentials"); 
} 


function getSecretData(){ 
    return { 
     secretData: "A secret data to invoke authentication" 
    }; 
} 

function onLogout(){ 
    WL.Logger.debug("Logged out"); 
} 

AuthenticationConfig.xml

<?xml version="1.0" encoding="UTF-8"?> 
<tns:loginConfiguration xmlns:tns="http://www.worklight.com/auth/config" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 

     <!-- Licensed Materials - Property of IBM 
      5725-I43 (C) Copyright IBM Corp. 2006, 2013. All Rights Reserved. 
      US Government Users Restricted Rights - Use, duplication or 
      disclosure restricted by GSA ADP Schedule Contract with IBM Corp. --> 

    <staticResources> 
    <!-- 
      <resource id="logUploadServlet" securityTest="LogUploadServlet"> 
      <urlPatterns>/apps/services/loguploader*</urlPatterns> 
     </resource> 
     --> 
     <resource id="subscribeServlet" securityTest="SubscribeServlet"> 
      <urlPatterns>/subscribeSMS*;/receiveSMS*;/ussd*</urlPatterns> 
     </resource> 

    </staticResources> 


    <securityTests> 

     <customSecurityTest name="SubscribeServlet"> 
      <test realm="SubscribeServlet" isInternalUserID="true" isInternalDeviceID="true"/> 
     </customSecurityTest> 

     <customSecurityTest name="SingleStepAuthAdapter-securityTest"> 
      <test isInternalUserID="true" realm="SingleStepAuthRealm"/> 
     </customSecurityTest> 

     <mobileSecurityTest name="PushApplication-mobile-securityTest"> 
      <testUser realm="SingleStepAuthRealm"/> 
      <testDeviceId provisioningType="none"/> 
     </mobileSecurityTest > 

    </securityTests> 

    <realms> 

    <realm loginModule="AuthLoginModule" name="SingleStepAuthRealm"> 
      <className>com.worklight.integration.auth.AdapterAuthenticator</className> 
      <parameter name="login-function" value="TaskAdapter.onAuthRequired"/> 
      <parameter name="logout-function" value="TaskAdapter.onLogout"/> 
     </realm> 
     <realm name="SampleAppRealm" loginModule="StrongDummy"> 
      <className>com.worklight.core.auth.ext.FormBasedAuthenticator</className> 
     </realm> 

     <realm name="SubscribeServlet" loginModule="rejectAll"> 
      <className>com.worklight.core.auth.ext.HeaderAuthenticator</className>   
     </realm> 

    </realms> 

    <loginModules> 
     <loginModule name="AuthLoginModule"> 
      <className>com.worklight.core.auth.ext.NonValidatingLoginModule</className> 
     </loginModule> 

     <loginModule name="StrongDummy" expirationInSeconds="-1"> 
      <className>com.worklight.core.auth.ext.NonValidatingLoginModule</className> 
     </loginModule> 

     <loginModule name="requireLogin" expirationInSeconds="-1"> 
      <className>com.worklight.core.auth.ext.SingleIdentityLoginModule</className> 
     </loginModule> 

     <loginModule name="rejectAll"> 
      <className>com.worklight.core.auth.ext.RejectingLoginModule</className> 
     </loginModule> 

    </loginModules> 

</tns:loginConfiguration> 

logcat的日誌

04-29 16:38:21.997 20704-20704/com.vdot.pushdemo D/ViewRootImpl﹕ ViewPostImeInputStage ACTION_DOWN 
04-29 16:38:41.417 20704-20711/com.vdot.pushdemo I/jdwp﹕ Ignoring second debugger -- accepting and dropping 
04-29 16:39:42.957 21735-21735/com.vdot.pushdemo I/System.out﹕ Sending WAIT chunk 
04-29 16:39:42.957 21735-21735/com.vdot.pushdemo W/ActivityThread﹕ Application com.vdot.pushdemo is waiting for the debugger on port 8100... 
04-29 16:39:42.967 21735-21741/com.vdot.pushdemo I/dalvikvm﹕ Debugger is active 
04-29 16:39:43.167 21735-21735/com.vdot.pushdemo I/System.out﹕ Debugger has connected 
04-29 16:39:43.167 21735-21735/com.vdot.pushdemo I/System.out﹕ waiting for debugger to settle... 
04-29 16:39:43.367 21735-21735/com.vdot.pushdemo I/System.out﹕ waiting for debugger to settle... 
04-29 16:39:43.567 21735-21735/com.vdot.pushdemo I/System.out﹕ waiting for debugger to settle... 
04-29 16:39:43.567 21735-21741/com.vdot.pushdemo I/jdwp﹕ Ignoring second debugger -- accepting and dropping 
04-29 16:39:43.777 21735-21735/com.vdot.pushdemo I/System.out﹕ waiting for debugger to settle... 
04-29 16:39:43.977 21735-21735/com.vdot.pushdemo I/System.out﹕ waiting for debugger to settle... 
04-29 16:39:44.167 21735-21735/com.vdot.pushdemo I/System.out﹕ waiting for debugger to settle... 
04-29 16:39:44.367 21735-21735/com.vdot.pushdemo I/System.out﹕ waiting for debugger to settle... 
04-29 16:39:44.577 21735-21735/com.vdot.pushdemo I/System.out﹕ debugger has settled (1321) 
04-29 16:39:44.667 21735-21735/com.vdot.pushdemo D/Activity﹕ #1 setTransGradationModeColor false 
04-29 16:39:44.727 21735-21735/com.vdot.pushdemo I/Adreno-EGL﹕ <qeglDrvAPI_eglInitialize:410>: EGL 1.4 QUALCOMM build: () 
    OpenGL ES Shader Compiler Version: E031.24.02.11 
    Build Date: 09/12/14 Fri 
    Local Branch: LA.3.6.1_20140912_070_patches 
    Remote Branch: 
    Local Patches: 
    Reconstruct Branch: 
04-29 16:39:44.737 21735-21735/com.vdot.pushdemo I/HWUI﹕ EGLImpl-HWUI Protected EGL context created 
04-29 16:39:44.747 21735-21735/com.vdot.pushdemo I/qdutils﹕ PartialUpdate status: Enabled 
04-29 16:39:44.747 21735-21735/com.vdot.pushdemo I/qdutils﹕ Left Align: 8 
04-29 16:39:44.747 21735-21735/com.vdot.pushdemo I/qdutils﹕ Width Align: 8 
04-29 16:39:44.747 21735-21735/com.vdot.pushdemo I/qdutils﹕ Top Align: 1 
04-29 16:39:44.747 21735-21735/com.vdot.pushdemo I/qdutils﹕ Height Align: 1 
04-29 16:39:44.747 21735-21735/com.vdot.pushdemo I/qdutils﹕ Min ROI Width: 1 
04-29 16:39:44.747 21735-21735/com.vdot.pushdemo I/qdutils﹕ Min ROI Height: 2 
04-29 16:39:44.747 21735-21735/com.vdot.pushdemo I/qdutils﹕ Needs ROI Merge: 1 
04-29 16:39:44.747 21735-21735/com.vdot.pushdemo I/qdutils﹕ Left Split=720 
04-29 16:39:44.747 21735-21735/com.vdot.pushdemo I/qdutils﹕ Right Split=720 
04-29 16:39:44.757 21735-21735/com.vdot.pushdemo D/OpenGLRenderer﹕ Enabling debug mode 0 
04-29 16:40:03.527 21735-21735/com.vdot.pushdemo D/ViewRootImpl﹕ ViewPostImeInputStage ACTION_DOWN 
04-29 16:40:04.077 21735-21735/com.vdot.pushdemo I/dalvikvm﹕ Could not find method android.content.pm.PackageManager.getPackageInstaller, referenced from method com.google.android.gms.common.GooglePlayServicesUtil.zzh 
04-29 16:40:04.077 21735-21735/com.vdot.pushdemo W/dalvikvm﹕ VFY: unable to resolve virtual method 529: Landroid/content/pm/PackageManager;.getPackageInstaller()Landroid/content/pm/PackageInstaller; 
04-29 16:40:04.077 21735-21735/com.vdot.pushdemo D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x000b 
04-29 16:40:04.087 21735-21735/com.vdot.pushdemo W/GooglePlayServicesUtil﹕ Google Play services out of date. Requires 7327000 but found 7099030 
04-29 16:40:04.097 21735-21758/com.vdot.pushdemo W/com.worklight.common.Logger﹕ com.worklight.common.Logger.setContext(Context) must be called to fully enable debug log capture. Currently, the 'capture' flag is set but the 'context' field is not. This warning will only be printed once. 
04-29 16:40:04.097 21735-21758/com.vdot.pushdemo D/GCMClientFactory﹕ GCMClientFactory.useGooglePlayServices in GCMClientFactory.java:38 :: Failed to use Google Play Services becuase the return code is 2 
04-29 16:40:04.107 21735-21758/com.vdot.pushdemo D/GCMClientFactory﹕ GCMClientFactory.getInstance in GCMClientFactory.java:28 :: Using GCMHelperClient 
04-29 16:40:04.117 21735-21735/com.vdot.pushdemo I/dalvikvm﹕ Could not find method android.app.Notification$Builder.setColor, referenced from method com.worklight.wlclient.push.GCMIntentService.generateNotification 
04-29 16:40:04.117 21735-21735/com.vdot.pushdemo W/dalvikvm﹕ VFY: unable to resolve virtual method 239: Landroid/app/Notification$Builder;.setColor (I)Landroid/app/Notification$Builder; 
04-29 16:40:04.117 21735-21735/com.vdot.pushdemo D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x0039 
04-29 16:40:04.117 21735-21735/com.vdot.pushdemo D/dalvikvm﹕ DexOpt: couldn't find field Landroid/app/Notification;.visibility 
04-29 16:40:04.117 21735-21735/com.vdot.pushdemo W/dalvikvm﹕ VFY: unable to resolve instance field 31 
04-29 16:40:04.117 21735-21735/com.vdot.pushdemo D/dalvikvm﹕ VFY: replacing opcode 0x59 at 0x0029 
04-29 16:40:04.117 21735-21735/com.vdot.pushdemo D/dalvikvm﹕ DexOpt: couldn't find field Landroid/app/Notification;.publicVersion 
04-29 16:40:04.117 21735-21735/com.vdot.pushdemo I/dalvikvm﹕ DexOpt: unable to optimize instance field ref 0x001b at 0x62 in Lcom/worklight/wlclient/push/GCMIntentService;.notify 
04-29 16:40:04.117 21735-21735/com.vdot.pushdemo D/dalvikvm﹕ DexOpt: couldn't find field Landroid/app/Notification;.category 
04-29 16:40:04.117 21735-21735/com.vdot.pushdemo I/dalvikvm﹕ DexOpt: unable to optimize instance field ref 0x000d at 0x72 in Lcom/worklight/wlclient/push/GCMIntentService;.notify 
04-29 16:40:04.137 21735-21758/com.vdot.pushdemo W/GCMHelperClient﹕ GCMHelperClient.unregisterReceivers in GCMHelperClient.java:95 :: unregister:Receiver not registered: null 
04-29 16:40:04.137 21735-21758/com.vdot.pushdemo W/GCMHelperClient﹕ GCMHelperClient.unregisterReceivers in GCMHelperClient.java:101 :: unregister:Receiver not registered: null 
04-29 16:40:04.147 21735-21758/com.vdot.pushdemo W/com.worklight.wlclient.api.WLPush﹕ WLPush.unregisterReceivers in WLPush.java:792 :: unregisterReceivers:Receiver not registered: [email protected] 
04-29 16:40:04.197 21735-21735/com.vdot.pushdemo I/Choreographer﹕ Skipped 32 frames! The application may be doing too much work on its main thread. 
04-29 16:40:04.227 21735-21758/com.vdot.pushdemo D/wl.request﹕ WLRequestSender.run in WLRequestSender.java:40 :: Sending request http://10.136.78.232:10080/MFPushDemo/apps/services/api/AndroidPushDemo/Androidnative/init 
04-29 16:40:04.237 21735-21759/com.vdot.pushdemo I/System.out﹕ Thread-25957(ApacheHTTPLog):Reading from variable values from setDefaultValuesToVariables 
04-29 16:40:04.257 21735-21759/com.vdot.pushdemo I/System.out﹕ Thread-25957(ApacheHTTPLog):isShipBuild true 
04-29 16:40:04.257 21735-21759/com.vdot.pushdemo I/System.out﹕ Thread-25957(ApacheHTTPLog):SmartBonding Enabling is true, SHIP_BUILD is true, log to file is false, DBG is false 
04-29 16:40:04.547 21735-21759/com.vdot.pushdemo I/System.out﹕ pool-3-thread-1 calls detatch() 
04-29 16:40:06.777 21735-21758/com.vdot.pushdemo D/wl.request﹕ WLRequestSender.run in WLRequestSender.java:40 :: Sending request http://10.136.78.232:10080/MFPushDemo/invoke 
04-29 16:40:06.977 21735-21760/com.vdot.pushdemo I/System.out﹕ pool-3-thread-2 calls detatch() 
04-29 16:40:07.017 21735-21758/com.vdot.pushdemo D/wl.request﹕ WLRequestSender.run in WLRequestSender.java:40 :: Sending request http://10.136.78.232:10080/MFPushDemo/apps/services/api/AndroidPushDemo/Androidnative/init 
04-29 16:40:07.317 21735-21763/com.vdot.pushdemo I/System.out﹕ pool-3-thread-3 calls detatch() 
04-29 16:40:07.387 21735-21758/com.vdot.pushdemo D/wl.request﹕ WLRequestSender.run in WLRequestSender.java:40 :: Sending request http://10.136.78.232:10080/MFPushDemo/apps/services/api/AndroidPushDemo/Androidnative/init 
04-29 16:40:07.817 21735-21765/com.vdot.pushdemo I/System.out﹕ pool-3-thread-4 calls detatch() 
04-29 16:40:07.867 21735-21765/com.vdot.pushdemo D/com.demo.push﹕ Mode Connect Success 
04-29 16:41:24.987 21735-21735/com.vdot.pushdemo D/ViewRootImpl﹕ ViewPostImeInputStage ACTION_DOWN 
04-29 16:42:18.697 21735-21735/com.vdot.pushdemo D/ViewRootImpl﹕ ViewPostImeInputStage ACTION_DOWN 
04-29 16:42:18.857 21735-21758/com.vdot.pushdemo D/WLClient﹕ WLClient.createInstance in WLClient.java:213 :: WLClient has already been created. 
04-29 16:42:18.877 21735-21735/com.vdot.pushdemo W/GooglePlayServicesUtil﹕ Google Play services out of date. Requires 7327000 but found 7099030 
04-29 16:42:18.897 21735-21758/com.vdot.pushdemo D/GCMClientFactory﹕ GCMClientFactory.useGooglePlayServices in GCMClientFactory.java:38 :: Failed to use Google Play Services becuase the return code is 2 
04-29 16:42:18.917 21735-21758/com.vdot.pushdemo D/GCMClientFactory﹕ GCMClientFactory.getInstance in GCMClientFactory.java:28 :: Using GCMHelperClient 
04-29 16:42:18.937 21735-21758/com.vdot.pushdemo W/GCMHelperClient﹕ GCMHelperClient.unregisterReceivers in GCMHelperClient.java:95 :: unregister:Receiver not registered: null 
04-29 16:42:18.967 21735-21758/com.vdot.pushdemo W/GCMHelperClient﹕ GCMHelperClient.unregisterReceivers in GCMHelperClient.java:101 :: unregister:Receiver not registered: null 
04-29 16:42:18.997 21735-21758/com.vdot.pushdemo W/com.worklight.wlclient.api.WLPush﹕ WLPush.unregisterReceivers in WLPush.java:792 :: unregisterReceivers:Receiver not registered: [email protected] 
04-29 16:42:19.017 21735-21758/com.vdot.pushdemo D/wl.request﹕ WLRequestSender.run in WLRequestSender.java:40 :: Sending request http://10.136.78.232:10080/MFPushDemo/apps/services/api/AndroidPushDemo/Androidnative/init 
04-29 16:42:19.227 21735-21809/com.vdot.pushdemo I/System.out﹕ pool-3-thread-5 calls detatch() 
04-29 16:42:19.277 21735-21809/com.vdot.pushdemo D/com.demo.push﹕ Mode Connect Success 
04-29 16:42:22.257 21735-21735/com.vdot.pushdemo D/ViewRootImpl﹕ ViewPostImeInputStage ACTION_DOWN 
04-29 16:42:22.427 21735-21758/com.vdot.pushdemo D/WLClient﹕ WLClient.createInstance in WLClient.java:213 :: WLClient has already been created. 
04-29 16:42:22.477 21735-21758/com.vdot.pushdemo D/wl.request﹕ WLRequestSender.run in WLRequestSender.java:40 :: Sending request http://10.136.78.232:10080/MFPushDemo/apps/services/api/AndroidPushDemo/Androidnative/init 
04-29 16:42:22.567 21735-21758/com.vdot.pushdemo D/wl.request﹕ WLRequestSender.run in WLRequestSender.java:40 :: Sending request http://10.136.78.232:10080/MFPushDemo/apps/services/api/AndroidPushDemo/Androidnative/query 
04-29 16:42:22.897 21735-21815/com.vdot.pushdemo I/System.out﹕ pool-3-thread-6 calls detatch() 
04-29 16:42:22.927 21735-21815/com.vdot.pushdemo D/com.demo.push﹕ Mode Connect Success 
04-29 16:42:23.007 21735-21759/com.vdot.pushdemo I/System.out﹕ pool-3-thread-1 calls detatch() 
04-29 16:42:23.027 21735-21759/com.vdot.pushdemo D/com.demo.push﹕ Mode Connect Success 
04-29 16:42:33.637 21735-21735/com.vdot.pushdemo D/ViewRootImpl﹕ ViewPostImeInputStage ACTION_DOWN 
04-29 16:42:33.877 21735-21758/com.vdot.pushdemo D/WLClient﹕ WLClient.createInstance in WLClient.java:213 :: WLClient has already been created. 
04-29 16:42:33.897 21735-21735/com.vdot.pushdemo W/GooglePlayServicesUtil﹕ Google Play services out of date. Requires 7327000 but found 7099030 
04-29 16:42:33.917 21735-21758/com.vdot.pushdemo D/GCMClientFactory﹕ GCMClientFactory.useGooglePlayServices in GCMClientFactory.java:38 :: Failed to use Google Play Services becuase the return code is 2 
04-29 16:42:33.927 21735-21758/com.vdot.pushdemo D/GCMClientFactory﹕ GCMClientFactory.getInstance in GCMClientFactory.java:28 :: Using GCMHelperClient 
04-29 16:42:33.957 21735-21758/com.vdot.pushdemo W/GCMHelperClient﹕ GCMHelperClient.unregisterReceivers in GCMHelperClient.java:95 :: unregister:Receiver not registered: null 
04-29 16:42:33.987 21735-21758/com.vdot.pushdemo W/GCMHelperClient﹕ GCMHelperClient.unregisterReceivers in GCMHelperClient.java:101 :: unregister:Receiver not registered: null 
04-29 16:42:34.007 21735-21758/com.vdot.pushdemo W/com.worklight.wlclient.api.WLPush﹕ WLPush.unregisterReceivers in WLPush.java:792 :: unregisterReceivers:Receiver not registered: [email protected] 
04-29 16:42:34.037 21735-21758/com.vdot.pushdemo D/wl.request﹕ WLRequestSender.run in WLRequestSender.java:40 :: Sending request http://10.136.78.232:10080/MFPushDemo/apps/services/api/AndroidPushDemo/Androidnative/init 
04-29 16:42:34.337 21735-21760/com.vdot.pushdemo I/System.out﹕ pool-3-thread-2 calls detatch() 
04-29 16:42:34.367 21735-21760/com.vdot.pushdemo D/com.demo.push﹕ Mode Connect Success 

更新的日誌

04-30 09:22:38.027 30652-30652/com.vdot.pushdemo I/Choreographer﹕ Skipped 34 frames! The application may be doing too much work on its main thread. 
04-30 09:22:38.037 30652-31058/com.vdot.pushdemo D/wl.request﹕ WLRequestSender.run in WLRequestSender.java:40 :: Sending request http://10.136.78.232:10080/MFPushDemo/apps/services/api/AndroidPushDemo/Androidnative/init 
04-30 09:22:38.047 30652-31059/com.vdot.pushdemo I/System.out﹕ Thread-26598(ApacheHTTPLog):Reading from variable values from setDefaultValuesToVariables 
04-30 09:22:38.077 30652-31059/com.vdot.pushdemo I/System.out﹕ Thread-26598(ApacheHTTPLog):isShipBuild true 
04-30 09:22:38.077 30652-31059/com.vdot.pushdemo I/System.out﹕ Thread-26598(ApacheHTTPLog):SmartBonding Enabling is true, SHIP_BUILD is true, log to file is false, DBG is false 
04-30 09:22:38.297 30652-31059/com.vdot.pushdemo I/System.out﹕ pool-3-thread-1 calls detatch() 
04-30 09:22:40.617 30652-31058/com.vdot.pushdemo D/wl.request﹕ WLRequestSender.run in WLRequestSender.java:40 :: Sending request http://10.136.78.232:10080/MFPushDemo/invoke 
04-30 09:22:40.737 30652-31064/com.vdot.pushdemo I/System.out﹕ pool-3-thread-2 calls detatch() 
04-30 09:22:40.767 30652-31058/com.vdot.pushdemo D/wl.request﹕ WLRequestSender.run in WLRequestSender.java:40 :: Sending request http://10.136.78.232:10080/MFPushDemo/apps/services/api/AndroidPushDemo/Androidnative/init 
04-30 09:22:40.897 30652-31067/com.vdot.pushdemo I/System.out﹕ pool-3-thread-3 calls detatch() 
04-30 09:22:40.947 30652-31058/com.vdot.pushdemo D/wl.request﹕ WLRequestSender.run in WLRequestSender.java:40 :: Sending request http://10.136.78.232:10080/MFPushDemo/apps/services/api/AndroidPushDemo/Androidnative/init 
04-30 09:22:41.197 30652-31069/com.vdot.pushdemo I/System.out﹕ pool-3-thread-4 calls detatch() 
04-30 09:22:41.227 30652-31058/com.vdot.pushdemo D/com.worklight.wlclient.api.WLPush﹕ WLPush.updateToken in WLPush.java:521 :: Registering at the GCM server. 
04-30 09:22:41.237 30652-31058/com.vdot.pushdemo D/com.worklight.wlclient.api.WLPush﹕ WLPush.clearSubscribedEventSources in WLPush.java:596 :: Clearing notification subscriptions. 
04-30 09:22:41.247 30652-31058/com.vdot.pushdemo D/com.worklight.wlclient.api.WLPush﹕ WLPush.clearSubscribedTags in WLPush.java:607 :: Clearing tag notification subscriptions. 
04-30 09:22:41.257 30652-31058/com.vdot.pushdemo D/com.worklight.wlclient.api.WLPush﹕ WLPush.updateSubscribedTags in WLPush.java:635 :: Updating tag notification subscriptions. 
04-30 09:22:41.257 30652-31069/com.vdot.pushdemo D/com.demo.push﹕ Mode Connect Success 
04-30 09:22:41.527 30652-31058/com.vdot.pushdemo D/GCMAPIClient﹕ GCMAPIClient$1.doInBackground in GCMAPIClient.java:45 :: Successfully registered with GCM using Google Play Services. Returned deviceToken:APA91bHvvCrMUQr-zI-CEjbmu3R7r7s_f9jPAMyBslPnQd16DPTveB96nzvYXRRIrzv_HbbMLdPitz-VjmhFKSZnFfC349IRSADxmfDm0h4ps82YUeTAGMUepUZhwrb7V24ExHLilp0qmcryQcn3pnmCOhPuJc6vZQ 
04-30 09:22:41.537 30652-31058/com.vdot.pushdemo D/com.worklight.wlclient.api.WLPush﹕ WLPush.updateTokenCallback in WLPush.java:756 :: Push notification device token has changed, Updating on server [serverToken: null, deviceToken: APA91bHvvCrMUQr-zI-CEjbmu3R7r7s_f9jPAMyBslPnQd16DPTveB96nzvYXRRIrzv_HbbMLdPitz-VjmhFKSZnFfC349IRSADxmfDm0h4ps82YUeTAGMUepUZhwrb7V24ExHLilp0qmcryQcn3pnmCOhPuJc6vZQ] 
04-30 09:22:41.567 30652-31058/com.vdot.pushdemo D/wl.request﹕ WLRequestSender.run in WLRequestSender.java:40 :: Sending request http://10.136.78.232:10080/MFPushDemo/apps/services/api/AndroidPushDemo/Androidnative/notifications 
04-30 09:22:42.407 30652-31078/com.vdot.pushdemo I/System.out﹕ pool-3-thread-5 calls detatch() 
04-30 09:22:49.337 30652-31078/com.vdot.pushdemo D/com.demo.push﹕ onReadyToSubscribe 
04-30 09:23:24.177 30652-30652/com.vdot.pushdemo D/ViewRootImpl﹕ ViewPostImeInputStage ACTION_DOWN 
04-30 09:23:24.337 30652-31058/com.vdot.pushdemo D/WLClient﹕ WLClient.createInstance in WLClient.java:213 :: WLClient has already been created. 
04-30 09:23:24.377 30652-31058/com.vdot.pushdemo D/GCMClientFactory﹕ GCMClientFactory.getInstance in GCMClientFactory.java:25 :: Using GCMAPIClient 
04-30 09:23:24.397 30652-31058/com.vdot.pushdemo W/com.worklight.wlclient.api.WLPush﹕ WLPush.unregisterReceivers in WLPush.java:792 :: unregisterReceivers:Receiver not registered: [email protected] 
04-30 09:23:24.427 30652-31058/com.vdot.pushdemo D/wl.request﹕ WLRequestSender.run in WLRequestSender.java:40 :: Sending request http://10.136.78.232:10080/MFPushDemo/apps/services/api/AndroidPushDemo/Androidnative/init 
04-30 09:23:24.617 30652-31085/com.vdot.pushdemo I/System.out﹕ pool-3-thread-6 calls detatch() 
04-30 09:23:24.657 30652-31058/com.vdot.pushdemo D/com.worklight.wlclient.api.WLPush﹕ WLPush.updateToken in WLPush.java:521 :: Registering at the GCM server. 
04-30 09:23:24.677 30652-31058/com.vdot.pushdemo D/com.worklight.wlclient.api.WLPush﹕ WLPush.clearSubscribedEventSources in WLPush.java:596 :: Clearing notification subscriptions. 
04-30 09:23:24.687 30652-31058/com.vdot.pushdemo D/com.worklight.wlclient.api.WLPush﹕ WLPush.updateSubscribedEventSources in WLPush.java:614 :: Updating notification subscriptions. 
04-30 09:23:24.697 30652-31085/com.vdot.pushdemo D/com.demo.push﹕ Mode Connect Success 
04-30 09:23:24.697 30652-31058/com.vdot.pushdemo D/com.worklight.wlclient.api.WLPush﹕ WLPush.clearSubscribedTags in WLPush.java:607 :: Clearing tag notification subscriptions. 
04-30 09:23:24.707 30652-31058/com.vdot.pushdemo D/com.worklight.wlclient.api.WLPush﹕ WLPush.updateSubscribedTags in WLPush.java:635 :: Updating tag notification subscriptions. 
04-30 09:23:24.807 30652-31058/com.vdot.pushdemo D/GCMAPIClient﹕ GCMAPIClient$1.doInBackground in GCMAPIClient.java:45 :: Successfully registered with GCM using Google Play Services. Returned deviceToken:APA91bHvvCrMUQr-zI-CEjbmu3R7r7s_f9jPAMyBslPnQd16DPTveB96nzvYXRRIrzv_HbbMLdPitz-VjmhFKSZnFfC349IRSADxmfDm0h4ps82YUeTAGMUepUZhwrb7V24ExHLilp0qmcryQcn3pnmCOhPuJc6vZQ 
04-30 09:23:24.817 30652-31086/com.vdot.pushdemo D/com.demo.push﹕ onReadyToSubscribe 
04-30 09:24:08.677 30652-30652/com.vdot.pushdemo D/ViewRootImpl﹕ ViewPostImeInputStage ACTION_DOWN 
04-30 09:24:08.877 30652-31058/com.vdot.pushdemo D/WLClient﹕ WLClient.createInstance in WLClient.java:213 :: WLClient has already been created. 
04-30 09:24:08.917 30652-31058/com.vdot.pushdemo D/GCMClientFactory﹕ GCMClientFactory.getInstance in GCMClientFactory.java:25 :: Using GCMAPIClient 
04-30 09:24:08.927 30652-31058/com.vdot.pushdemo W/com.worklight.wlclient.api.WLPush﹕ WLPush.unregisterReceivers in WLPush.java:792 :: unregisterReceivers:Receiver not registered: [email protected] 

搖籃

dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 

    compile 'com.android.support:appcompat-v7:22.0.0' 
    compile 'com.google.android.gms:play-services:7.0.0' 
} 
+0

因爲您說您已經登錄到應用程序,請嘗試在事件源上安全測試。這不是必需的。另外,從應用程序啓動時添加LogCat日誌,這可能與GCM配置相關。 –

+0

刪除了安全測試,但仍然沒有運氣。昨天,一位IBM員工已經遠程登錄到我的機器上,但仍然無法解決問題。 我被告知來自IBM創建一個全新的應用程序推送,而不是使用現有的應用程序,看看它是否工作。 – user3681378

+0

LogCat日誌怎麼樣? –

回答

0

從它出現您正在使用過期的谷歌播放服務的logcat日誌:

04 -29 16:42:33.897 21735-21735/com.vdot.pus hdemo W/GooglePlayServicesUtil:Google Play服務已過期。需要 7327000但發現7099030 04-29 16:42:33.917 21735-21758/com.vdot.pushdemo d/GCMClientFactory: GCMClientFactory.useGooglePlayServices在GCMClientFactory.java:38 :: 無法使用谷歌播放服務,因爲返回代碼爲2

推送通知需要Google Play服務。如果此服務無法初始化,推送可能確實不起作用。

打開Android SDK Manager,更新Play Services組件並確保應用程序已正確配置以使用它。然後再試一次。

+0

嗨Idan,由SDK的Google Play服務更新。更新後,我去了Android \ android sdk \ extras \ google \ m2repository \ com \ google \ android \ gms \ play-services 並且檢查了我的版本號。我有最新的7.3.0,但是當我在build.gradle中加入7.3.0時,它要求我更新設備上的google play服務。我沒有該設備更新的授權,所以我繼續並將版本號更改爲7.0.0。註冊已成功,但收到消息,如無法訂閱,通知令牌未在服務器上更新「。也發佈更新日誌。 – user3681378

相關問題