gpt4 book ai didi

android - Urbanairship android 无法获取 APID()

转载 作者:行者123 更新时间:2023-11-29 17:45:59 26 4
gpt4 key购买 nike

我正在尝试对示例 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): Request failed. URL: https://device-api.urbanairship.com/api/channels/18d12d4c-a906-415e-abe9-e9b36fd939e5 requestMethod: PUT 11-03 11:15:16.292: E/Push Sample - UALib(26288): javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found. 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): at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65) 11-03 11:15:16.292: E/Push Sample - UALib(26288): at android.os.Handler.dispatchMessage(Handler.java:110) 11-03 11:15:16.292: E/Push Sample - UALib(26288): at android.os.Looper.loop(Looper.java:193) 11-03 11:15:16.292: E/Push Sample - UALib(26288): at android.os.HandlerThread.run(HandlerThread.java:61) 11-03 11:15:16.292: E/Push Sample - UALib(26288): Caused by: java.security.cert.CertificateException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found. 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 more 11-03 11:15:16.292: E/Push Sample - UALib(26288): Caused by: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found. 11-03 11:15:16.292: E/Push Sample - UALib(26288): ... 25 more 11-03 11:15:16.293: E/Push Sample - UALib(26288): Failed to receive channel response. 11-03 11:15:16.294: E/Push Sample - UALib(26288): Channel registration failed, will retry. 11-03 11:15:16.295: I/Push Sample - UALib(26288): Rescheduling push service com.urbanairship.push.ACTION_RETRY_CHANNEL_REGISTRATION in 1280000 milliseconds.

最佳答案

Urban Airship 5.x系列不再使用API​​D。取而代之的是使用新的“ channel ”标识符。它与 APID 基本相同。此外, channel 很可能在起飞结束时不可用。它们需要 http 请求来生成和设置。相反,您应该添加一个广播接收器,以便在生成 channel 时收到通知。参见 http://docs.urbanairship.com/build/push/android_features.html#listening-for-push-events了解更多详情。

关于android - Urbanairship android 无法获取 APID(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26717398/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com