0

我已將worklight項目從worklight 6.1升級到mobilefirst 7.1。在之前的項目(WL6.1)中,pushnotification工作正常。將Google Play服務添加到Android項目以進行推送通知有什麼意義?

對於mobilefirst,在檢查ibm教程時,我發現此鏈接用於將Google Play服務添加到您的Android項目。

http://www.ibm.com/support/knowledgecenter/en/SSHS8R_7.1.0/com.ibm.worklight.dev.doc/devref/t_adding_google_play_services.html

對於pushnotification,需要此步驟?根據鏈接,它會增加我的應用程序的大小。哄騙Google服務庫有什麼意義?我可以跳過嗎?

在mobilefirst配置的Android 7.1 pushnotification(除加古爾服務)之後,我對着在服務器端這個錯誤

com.ibm.pushworks.server.notification.gcm.GCMMediator addTokenToAndroidKey FPWSE1079W: GCM push token '@@[email protected]@' is not added to GCM notification key. GCM Service invocation failed (reason: Error while invoking request) 
            com.ibm.pushworks.server.exceptions.GCMException: GCM Service invocation failed (reason: Error while invoking request) 
     at com.ibm.pushworks.server.notification.gcm.GCMSender.sendToGCM(GCMSender.java:392) 
     at com.ibm.pushworks.server.notification.gcm.GCMSender.addTokenToAndroidKey(GCMSender.java:364) 
     at com.ibm.pushworks.server.notification.gcm.GCMMediator.addTokenToAndroidKey(GCMMediator.java:206) 
     at com.ibm.pushworks.server.core.PushServiceImpl.getNotificationKey(PushServiceImpl.java:2160) 
     at com.ibm.pushworks.server.core.PushServiceImpl.registerDevice(PushServiceImpl.java:613) 
     at com.worklight.integration.services.impl.DataAccessServiceImpl.updateDeviceToken(DataAccessServiceImpl.java:473) 
     ...... 

    Caused by: org.apache.http.conn.HttpHostConnectException: Connect to android.googleapis.com:443 [android.googleapis.com/216.58.210.202, android.googleapis.com/216.58.210.234] failed: Connection refused: connect 
     at org.apache.http.impl.conn.HttpClientConnectionOperator.connect(HttpClientConnectionOperator.java:142) 
     at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:319) 
     at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:363) 
     at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:219) 
     at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:195) 
     at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:86) 
     at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:108) 
     at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184) 
     at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82) 
     at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:106) 
     at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:57) 
     at com.ibm.pushworks.server.notification.gcm.GCMSender.sendToGCM(GCMSender.java:388) 
     ... 45 more 
    Caused by: java.net.ConnectException: Connection refused: connect 
     at java.net.PlainSocketImpl.socketConnect(Native Method) 
     at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:412) 
     at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:271) 
     at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:258) 
     at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:376) 
     at java.net.Socket.connect(Socket.java:546) 
     at org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:244) 
     at org.apache.http.impl.conn.HttpClientConnectionOperator.connect(HttpClientConnectionOperator.java:125) 
     ... 56 more 

這可以GCM口岸開放問題或有關谷歌播放服務?

+0

這是一個本地或混合應用程序? –

+0

這是一個混合應用程序 – John

回答

1

Google已經不贊成在項目中使用GCM.jar,並且從其角度來看,您應該使用Google Play服務庫。

但是,對於IBM MobileFirst Platform,如果您需要使用雲同步功能和其他功能(由Google),則需要Google Play服務庫。如果您不需要此功能,請不要添加庫,因爲MobileFirst SDK中仍有一個內置實現,用於使用GCM.jar進行推送通知。

注:

  1. 開始MobileFirst基金會8.0,現在需要的庫。
  2. 在v7.1中,無論內置回退如何,您仍然可以使用該庫,但您需要使用Android的ProGuard功能來減小類的大小以防止出現錯誤(「類太多」),並且一般要縮小尺寸。

至於網絡錯誤,看起來您的網絡配置不足(連接被拒絕)。該文檔還列出了Google要求他們打開/訪問才能正常運行的地址/端口。

相關問題