Advertisement
Guest User

Untitled

a guest
Nov 18th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.41 KB | None | 0 0
  1. package one.clockwork.pintwo;
  2.  
  3. import android.util.Log;
  4.  
  5. import com.google.firebase.iid.FirebaseInstanceId;
  6. import com.google.firebase.iid.FirebaseInstanceIdService;
  7.  
  8. import org.json.JSONArray;
  9. import org.json.JSONException;
  10. import org.json.JSONObject;
  11.  
  12. /**
  13.  * Created by Clockwork on 11.09.17.
  14.  */
  15.  
  16. public class InstanceIDService extends FirebaseInstanceIdService {
  17.  
  18.     @Override
  19.     public void onTokenRefresh() {
  20.         sendRegistrationToServer(FirebaseInstanceId.getInstance().getToken());
  21.     }
  22.  
  23.     private void sendRegistrationToServer(String token) {
  24.         API api = new API(this);
  25.         try {
  26.             api.setAppToken(token, new VolleyCallback() {
  27.                 @Override
  28.                 public void onSuccess(String result) {
  29.                     if(result.equals("ok"))
  30.                         Log.d("OK", result);
  31.                 }
  32.  
  33.                 @Override
  34.                 public void onSuccess(JSONObject result) {
  35.  
  36.                 }
  37.  
  38.                 @Override
  39.                 public void onSuccess(JSONArray array) {
  40.  
  41.                 }
  42.  
  43.                 @Override
  44.                 public void onSuccess(JSONObject param1, JSONObject param2) {
  45.  
  46.                 }
  47.  
  48.                 @Override
  49.                 public void onError(String error) {
  50.  
  51.                 }
  52.             });
  53.         } catch (JSONException e) {
  54.             e.printStackTrace();
  55.         }
  56.     }
  57.  
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement