Hi I am using appcelerator cloud service for push notifications in android native platform I followed the tutorial in the link http://cloud.appcelerator.com/docs/android and I was able to create user and login users successful but I am getting exception in retriving device token I used the following code in the OnCreate() method
CCPushService.getInstance().getDeviceTokenAsnyc(getApplicationContext(), APP_ID, new DeviceTokenCallback(){ public void receivedDeviceToken(final String deviceToken) { activityHandler.post(new Runnable(){ public void run() { mDeviceID = deviceToken; Log.e("TAG","token"+ mDeviceID); //((TextView) findViewById(R.id.target_text)).setText(mDeviceID); } }); } public void failedReceiveDeviceToken(Throwable exception) { Log.e("TAG","errorin token"+ exception.getMessage()); } });But it always calls failedReceiveDeviceToken() and returns like "Invalid token request". I am not getting whats going wrong please help to solve this. (I am using android sdk 3.2)
2 Answers
http://www.titaniumtutorial.com/2012/06/appcelerator-cloud-push-notification-in.html?showComment=1342709184145#c1044133421605435515
I do this tutorial and it works for me.
There is a bug in CCPushService there is a hardcoded local url:
String url = "http://192.168.1.27:9999/v1/push_notification/device_token.json?key=" + appKey + "&package=" + androidContext.getPackageName() + "&client_id=" + mDeviceID + "&version=1.1";You can use the following to get the device token:
String mDeviceID = ((TelephonyManager)androidContext.getSystemService("phone")).getDeviceId(); if ((mDeviceID == null) || (mDeviceID.equals(""))) { mDeviceID = "000000000000000"; } Cocoafish sdk = new Cocoafish("QjAbwp3l8AiPMiZJ3rW2RfjBEqKsfqVB"); // app key Map<String, Object> data = new HashMap<String, Object>(); data.put("package", androidContext.getPackageName()); data.put("client_id", mDeviceID); data.put("version", "1.1"); CCResponse response = sdk.sendRequest("push_notification/device_token.json", CCRequestMethod.GET, data);
Your Answer
Think you can help? Login to answer this question!