无法获得设备令牌Android(Appcelerator)

时间:2014-07-25 09:28:42

标签: android push-notification google-cloud-messaging appcelerator appcelerator-mobile

我无法获取在Android中使用ACS推送通知所需的设备令牌。我搜索了所有相关问题但没有得到答案。我按照指南Configuring push services for Android devicesSubscribing to push notifications进行了操作。

  • 申请类型移动
  • Titanium SDK: Titanium命令行界面,CLI版本3.3.0,Titanium SDK版本3.2.3.GA
  • 平台&版本: Android 4.3
  • 设备:小米红米1S
  • 主机操作系统: OSX 10
  • Titanium Studio: Titanium Studio,build:3.3.0.201407100905 Build:jenkins-titanium-rcp-master-164(origin / master)

TiApp

<modules>
 <module platform="commonjs">ti.cloud</module>
        <module platform="iphone">ti.map</module>
        <module platform="android">ti.map</module>
        <module platform="android" version="2.2.0">ti.cloudpush</module>
</modules>

如果没有设置ti.cloudpush 2.2.0版本,我在日志

中收到此错误
[ERROR] :  Found incompatible Titanium Modules:
[ERROR] :     id: ti.cloudpush   version: 3.3.0  platform: android   min sdk: undefined
[ERROR] Application Installer abnormal process termination. Process exit value was 1

相关代码

if (Ti.Platform.osname == "android") {
        var CloudPush = require('ti.cloudpush');
        CloudPush.retrieveDeviceToken({
            success : function deviceTokenSuccess(e) {
                // Use this device token with Ti.Cloud.PushNotifications calls
                // to subscribe and unsubscribe to push notification channels
                Alloy.Globals.tokenPush =   e.deviceToken;
                funciones.warn('Device Token: ' + e.deviceToken);
                funciones.suscribirCanal(param1,Alloy.Globals.tokenPush);
                //return token;
            },
            error : function deviceTokenError(e) {
                funciones.warn('Failed to register for push! ' + e.error);
            }
        });
        // These events monitor incoming push notifications
        CloudPush.addEventListener('callback', function(evt) {
            if(ostype === "android"){
                var alertString = JSON.parse(e.payload).android.alert;
                alert("Push recibido "+alertString);
            }


        });

    }

LOG STACKTRACE

[WARN] :   The module ti.cloudpush does not support the ABI: x86
[WARN] :   It only supports the following ABIs: armeabi, armeabi-v7a
[WARN] :   Your application will most likely encounter issues
[ERROR] :  E/com.appcelerator.cloud.push.CCPushService: Failed to request device token.
[ERROR] :  E/com.appcelerator.cloud.push.CCPushService: org.apache.http.conn.HttpHostConnectException: Connection to https://push-coordinator.cloud.appcelerator.com refused
[ERROR] :  E/com.appcelerator.cloud.push.CCPushService:     at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:183)
[ERROR] :  E/com.appcelerator.cloud.push.CCPushService:     at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
[ERROR] :  E/com.appcelerator.cloud.push.CCPushService:     at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
[ERROR] :  E/com.appcelerator.cloud.push.CCPushService:     at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:360)
[ERROR] :  E/com.appcelerator.cloud.push.CCPushService:     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
[ERROR] :  E/com.appcelerator.cloud.push.CCPushService:     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
[ERROR] :  E/com.appcelerator.cloud.push.CCPushService:     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
[ERROR] :  E/com.appcelerator.cloud.push.CCPushService:     at com.appcelerator.cloud.push.CCPushService.requestForDeviceToken(CCPushService.java:247)
[ERROR] :  E/com.appcelerator.cloud.push.CCPushService:     at com.appcelerator.cloud.push.CCPushService.getDeviceToken(CCPushService.java:82)
[ERROR] :  E/com.appcelerator.cloud.push.CCPushService:     at com.appcelerator.cloud.push.CCPushService.access$000(CCPushService.java:28)
[ERROR] :  E/com.appcelerator.cloud.push.CCPushService:     at com.appcelerator.cloud.push.CCPushService$1.run(CCPushService.java:172)
[ERROR] :  E/com.appcelerator.cloud.push.CCPushService:     at java.lang.Thread.run(Thread.java:841)
[ERROR] :  E/com.appcelerator.cloud.push.CCPushService: Caused by: java.net.ConnectException: failed to connect to /54.215.6.76 (port 443): connect failed: ETIMEDOUT (Connection timed out)
[ERROR] :  E/com.appcelerator.cloud.push.CCPushService:     at libcore.io.IoBridge.connect(IoBridge.java:114)
[ERROR] :  E/com.appcelerator.cloud.push.CCPushService:     at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:192)
[ERROR] :  E/com.appcelerator.cloud.push.CCPushService:     at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:460)
[ERROR] :  E/com.appcelerator.cloud.push.CCPushService:     at java.net.Socket.connect(Socket.java:832)
[ERROR] :  E/com.appcelerator.cloud.push.CCPushService:     at org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:119)
[ERROR] :  E/com.appcelerator.cloud.push.CCPushService:     at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:144)
[ERROR] :  E/com.appcelerator.cloud.push.CCPushService:     ... 11 more
[ERROR] :  E/com.appcelerator.cloud.push.CCPushService: Caused by: libcore.io.ErrnoException: connect failed: ETIMEDOUT (Connection timed out)
[ERROR] :  E/com.appcelerator.cloud.push.CCPushService:     at libcore.io.Posix.connect(Native Method)
[ERROR] :  E/com.appcelerator.cloud.push.CCPushService:     at libcore.io.BlockGuardOs.connect(BlockGuardOs.java:85)
[ERROR] :  E/com.appcelerator.cloud.push.CCPushService:     at libcore.io.IoBridge.connectErrno(IoBridge.java:127)
[ERROR] :  E/com.appcelerator.cloud.push.CCPushService:     at libcore.io.IoBridge.connect(IoBridge.java:112)
[ERROR] :  E/com.appcelerator.cloud.push.CCPushService:     ... 16 more
[ERROR] :  E/com.appcelerator.cloud.push.CCPushService: Invalid token request
[ERROR] :  E/com.appcelerator.cloud.push.CCPushService: org.apache.http.conn.HttpHostConnectException: Connection to https://push-coordinator.cloud.appcelerator.com refused
[ERROR] :  E/com.appcelerator.cloud.push.CCPushService:     at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:183)
[ERROR] :  E/com.appcelerator.cloud.push.CCPushService:     at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
[ERROR] :  E/com.appcelerator.cloud.push.CCPushService:     at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
[ERROR] :  E/com.appcelerator.cloud.push.CCPushService:     at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:360)
[ERROR] :  E/com.appcelerator.cloud.push.CCPushService:     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
[ERROR] :  E/com.appcelerator.cloud.push.CCPushService:     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
[ERROR] :  E/com.appcelerator.cloud.push.CCPushService:     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
[ERROR] :  E/com.appcelerator.cloud.push.CCPushService:     at com.appcelerator.cloud.push.CCPushService.requestForDeviceToken(CCPushService.java:247)
[ERROR] :  E/com.appcelerator.cloud.push.CCPushService:     at com.appcelerator.cloud.push.CCPushService.getDeviceToken(CCPushService.java:82)
[ERROR] :  E/com.appcelerator.cloud.push.CCPushService:     at com.appcelerator.cloud.push.CCPushService.access$000(CCPushService.java:28)
[ERROR] :  E/com.appcelerator.cloud.push.CCPushService:     at com.appcelerator.cloud.push.CCPushService$1.run(CCPushService.java:172)
[ERROR] :  E/com.appcelerator.cloud.push.CCPushService:     at java.lang.Thread.run(Thread.java:841)
[ERROR] :  E/com.appcelerator.cloud.push.CCPushService: Caused by: java.net.ConnectException: failed to connect to /54.215.6.76 (port 443): connect failed: ETIMEDOUT (Connection timed out)
[ERROR] :  E/com.appcelerator.cloud.push.CCPushService:     at libcore.io.IoBridge.connect(IoBridge.java:114)
[ERROR] :  E/com.appcelerator.cloud.push.CCPushService:     at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:192)
[ERROR] :  E/com.appcelerator.cloud.push.CCPushService:     at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:460)
[ERROR] :  E/com.appcelerator.cloud.push.CCPushService:     at java.net.Socket.connect(Socket.java:832)
[ERROR] :  E/com.appcelerator.cloud.push.CCPushService:     at org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:119)
[ERROR] :  E/com.appcelerator.cloud.push.CCPushService:     at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:144)
[ERROR] :  E/com.appcelerator.cloud.push.CCPushService:     ... 11 more
[ERROR] :  E/com.appcelerator.cloud.push.CCPushService: Caused by: libcore.io.ErrnoException: connect failed: ETIMEDOUT (Connection timed out)
[ERROR] :  E/com.appcelerator.cloud.push.CCPushService:     at libcore.io.Posix.connect(Native Method)
[ERROR] :  E/com.appcelerator.cloud.push.CCPushService:     at libcore.io.BlockGuardOs.connect(BlockGuardOs.java:85)
[ERROR] :  E/com.appcelerator.cloud.push.CCPushService:     at libcore.io.IoBridge.connectErrno(IoBridge.java:127)
[ERROR] :  E/com.appcelerator.cloud.push.CCPushService:     at libcore.io.IoBridge.connect(IoBridge.java:112)
[ERROR] :  E/com.appcelerator.cloud.push.CCPushService:     ... 16 more
[ERROR] :  CloudpushModule: (Thread-3453) [3700,63022] Failed to retrieve device token! See stack trace below for more information.
[WARN] :   W/System.err: com.appcelerator.cloud.push.PushServiceException: Invalid token request
[WARN] :   W/System.err:    at com.appcelerator.cloud.push.CCPushService.getDeviceToken(CCPushService.java:123)
[WARN] :   W/System.err:    at com.appcelerator.cloud.push.CCPushService.access$000(CCPushService.java:28)
[WARN] :   W/System.err:    at com.appcelerator.cloud.push.CCPushService$1.run(CCPushService.java:172)
[WARN] :   W/System.err:    at java.lang.Thread.run(Thread.java:841)
[WARN] :   Failed to register for push! com.appcelerator.cloud.push.PushServiceException: Invalid token request

我感谢任何帮助。提前谢谢。

1 个答案:

答案 0 :(得分:0)

您使用的版本不匹配

您的Ti CLI是SDK 3.3.0 您的SDK是3.2.3.GA 在工作室中,您似乎使用的是CI版本,即3.3.0.201407100905,其本质上将是不稳定的

我认为在第一个例子中你需要确保你的Ti安装是正确的,我首先要重新安装SDK到3.3.0.GA

然后使用:

<module platform="android">ti.cloudpush</module>

没有版本参数。如果此时无法编译,它会告诉你一些事情。即你的安装很糟糕。强制使用较低版本号只会强制使用旧的不兼容库版本