我正在尝试对示例android urbanairship进行测试推送。为此,我需要APID,因为要在Urbanairship填写的表单上的值需要以下字段:{Apid,Alert,Extra Key,Extra Value,Payload}。我认为至少我需要设置Apid,而Alert是要尝试的消息。要获得测试Apid,我需要通过调试运行运行PushManager.shared()。getAPID()。但是每次断点都会下降,我可以看到PushManager.shared()实例,我没有看到方法getAPID()。我正在反对urbanairship-lib-5.0.3.jar
我错过了什么吗?或者不再支持getAPID()?
好主意"向我们展示您的代码"。这是
public void onCreate() {
super.onCreate();
// Optionally, customize your config at runtime:
//
AirshipConfigOptions options = new AirshipConfigOptions();
options.inProduction = false;
options.gcmSender = "56221xxx”; // sampe GCM
options.developmentAppKey = "8xxxxxxmYGguX55Axxx”; // UA development push
options.developmentAppSecret = "FSgFIxxxxxxxxQ"; // UA development push
UAirship.takeOff(this, options);
PushManager pmgr = UAirship.shared().getPushManager();
pmgr.setUserNotificationsEnabled(true);
String strApId = pmgr.shared(). getAPID() // getAPID() it’s not there !!! :-(
// at this point, those objects above are live, ie. they aren’t null
}
所以我做了一些测试,我认为问题是由于ssl证书。 Logcat显示以下错误,但此时我不知道如何修复它们。
11-03 11:15:16.292:E / Push Sample - UALib(26288):请求失败。网址:https://device-api.urbanairship.com/api/channels/18d12d4c-a906-415e-abe9-e9b36fd939e5 requestMethod:PUT 11-03 11:15:16.292:E / Push示例 - UALib(26288):javax.net.ssl.SSLHandshakeException:java.security.cert.CertPathValidatorException:未找到证书路径的信任锚。 11-03 11:15:16.292:E / Push Sample - UALib(26288):at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:409) 11-03 11:15:16.292:E / Push Sample - UALib(26288):at com.android.okhttp.Connection.upgradeToTls(Connection.java:146) 11-03 11:15:16.292:E / Push Sample - UALib(26288):at com.android.okhttp.Connection.connect(Connection.java:107) 11-03 11:15:16.292:E / Push Sample - UALib(26288):at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:294) 11-03 11:15:16.292:E / Push Sample - UALib(26288):at com.android.okhttp.internal.http.HttpEngine.sendSocketRequest(HttpEngine.java:255) 11-03 11:15:16.292:E / Push Sample - UALib(26288):at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:206) 11-03 11:15:16.292:E / Push Sample - UALib(26288):at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:345) 11-03 11:15:16.292:E / Push Sample - UALib(26288):at com.android.okhttp.internal.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:89) 11-03 11:15:16.292:E / Push Sample - UALib(26288):at com.android.okhttp.internal.http.HttpURLConnectionImpl.getOutputStream(HttpURLConnectionImpl.java:197) 11-03 11:15:16.292:E / Push Sample - UALib(26288):at com.android.okhttp.internal.http.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:254) 11-03 11:15:16.292:E / Push Sample - UALib(26288):at com.urbanairship.http.Request.execute(Request.java:207) 11-03 11:15:16.292:E / Push Sample - UALib(26288):at com.urbanairship.push.ChannelAPIClient.requestWithPayload(ChannelAPIClient.java:104) 11-03 11:15:16.292:E / Push Sample - UALib(26288):at com.urbanairship.push.ChannelAPIClient.updateChannelWithPayload(ChannelAPIClient.java:89) 11-03 11:15:16.292:E / Push Sample - UALib(26288):at com.urbanairship.push.PushService.updateChannel(PushService.java:272) 11-03 11:15:16.292:E / Push Sample - UALib(26288):at com.urbanairship.push.PushService.performChannelRegistration(PushService.java:360) 11-03 11:15:16.292:E / Push Sample - UALib(26288):at com.urbanairship.push.PushService.onRetryChannelRegistration(PushService.java:259) 11-03 11:15:16.292:E / Push Sample - UALib(26288):at com.urbanairship.push.PushService.onHandleIntent(PushService.java:175) 11-03 11:15:16.292:E / Push Sample - UALib(26288):在android.app.IntentService $ ServiceHandler.handleMessage(IntentService.java:65) 11-03 11:15:16.292:E / Push Sample - UALib(26288):在android.os.Handler.dispatchMessage(Handler.java:110) 11-03 11:15:16.292:E / Push Sample - UALib(26288):在android.os.Looper.loop(Looper.java:193) 11-03 11:15:16.292:E / Push Sample - UALib(26288):在android.os.HandlerThread.run(HandlerThread.java:61) 11-03 11:15:16.292:E / Push示例 - UALib(26288):引起:java.security.cert.CertificateException:java.security.cert.CertPathValidatorException:未找到证书路径的信任锚。 11-03 11:15:16.292:E / Push Sample - UALib(26288):at com.android.org.conscrypt.TrustManagerImpl.checkTrusted(TrustManagerImpl.java:282) 11-03 11:15:16.292:E / Push Sample - UALib(26288):at com.android.org.conscrypt.TrustManagerImpl.checkServerTrusted(TrustManagerImpl.java:202) 11-03 11:15:16.292:E / Push Sample - UALib(26288):at com.android.org.conscrypt.OpenSSLSocketImpl.verifyCertificateChain(OpenSSLSocketImpl.java:611) 11-03 11:15:16.292:E / Push Sample - UALib(26288):at com.android.org.conscrypt.NativeCrypto.SSL_do_handshake(Native Method) 11-03 11:15:16.292:E / Push Sample - UALib(26288):at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:405) 11-03 11:15:16.292:E / Push Sample - UALib(26288):... 20多个 11-03 11:15:16.292:E / Push Sample - UALib(26288):引起:java.security.cert.CertPathValidatorException:未找到证书路径的信任锚。 11-03 11:15:16.292:E / Push Sample - UALib(26288):......还有25个 11-03 11:15:16.293:E / Push Sample - UALib(26288):无法接收通道响应。 11-03 11:15:16.294:E / Push Sample - UALib(26288):频道注册失败,将重试。 11-03 11:15:16.295:I / Push Sample - UALib(26288):在1280000毫秒内重新安排推送服务com.urbanairship.push.ACTION_RETRY_CHANNEL_REGISTRATION。
答案 0 :(得分:3)
APID不再用于5.x系列的Urban Airship。而是使用新的“通道”标识符。它与APID基本相同。此外,当起飞完成时,频道很可能无法使用。它们需要http请求来生成和设置。相反,您应该添加一个广播接收器,以便在生成通道时收到通知。有关详细信息,请参阅http://docs.urbanairship.com/build/push/android_features.html#listening-for-push-events。