I am trying to do a Test Push of the sample android urbanairship. To do that I need the APID, since the values on the form to fill out at Urbanairship requires the following fields: {Apid, Alert, Extra Key, Extra Value, Payload}. I think as a minimum I need to set the Apid, and the Alert is the message to try out. To get a test Apid, I need to run PushManager.shared().getAPID() through a debug run. However every time the break points drop where I can see PushManager.shared() instance, I don't see the method getAPID(). I am linking against urbanairship-lib-5.0.3.jar
Did I miss anything? Or is getAPID() no longer supported?
good idea about "show us your code". Here it is
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
}
So I did some more test and I think the problem is due to ssl certificates. Logcat is showing the following errors, however at this time I don't know how to fix them.
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.
APID is no longer used in the 5.x series of Urban Airship. Instead the new "channel" identifier is used. Its essentially the same as the APID. Also, the Channel will most likely not be available right when takeoff is finished. They require http requests to generate and set. Instead, you should add a broadcast receiver to be notified when the channel is generated. See http://docs.urbanairship.com/build/push/android_features.html#listening-for-push-events for more details.
来源:https://stackoverflow.com/questions/26717398/urbanairship-android-unable-to-getapid