Created
August 11, 2016 09:18
-
-
Save progress44/5b1e910776274744ad71f9b5c340fef7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (senderId != null) { | |
new AsyncTask<Void, Void, Void>() { | |
@Override | |
protected Void doInBackground(Void... params) { | |
try { | |
String token = getToken(senderId); | |
GcmPubSub.getInstance(TiApplication.getInstance()).subscribe(token, topic, null); | |
if (successTopicCallback != null) { | |
// send success callback | |
HashMap<String, Object> data = new HashMap<String, Object>(); | |
data.put("success", true); | |
data.put("topic", topic); | |
successTopicCallback.callAsync(getKrollObject(), data); | |
} | |
} catch (Exception ex) { | |
// error | |
Log.e(LCAT, "Error " + ex.toString()); | |
if (errorTopicCallback != null) { | |
// send error callback | |
HashMap<String, Object> data = new HashMap<String, Object>(); | |
data.put("success", false); | |
data.put("topic", topic); | |
data.put("error", ex.toString()); | |
errorCallback.callAsync(getKrollObject(), data); | |
} | |
} | |
return null; | |
} | |
}.execute(); | |
} else { | |
sendError(errorTopicCallback, "No GCM senderId specified; get it from the Google Play Developer Console"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment