Advertisement
Guest User

service

a guest
Mar 26th, 2018
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.40 KB | None | 0 0
  1. package app.vindict;
  2.  
  3. import android.content.Context;
  4. import android.content.Intent;
  5. import android.widget.Toast;
  6.  
  7. import com.backendless.push.BackendlessPushService;
  8.  
  9. public class MyPushService extends BackendlessPushService {
  10.     @Override
  11.     public void onRegistered(Context context, String registrationId) {
  12.         Toast.makeText(context,
  13.                 "device registered" + registrationId,
  14.                 Toast.LENGTH_SHORT).show();
  15.     }
  16.  
  17.     @Override
  18.     public void onUnregistered(Context context, Boolean unregistered) {
  19.         Toast.makeText(context,
  20.                 "device unregistered",
  21.                 Toast.LENGTH_SHORT).show();
  22.     }
  23.  
  24.     @Override
  25.     public boolean onMessage(Context context, Intent intent) {
  26.         String message = intent.getStringExtra("message");
  27.         Toast.makeText(context,
  28.                 "Push message received. Message: " + message,
  29.                 Toast.LENGTH_LONG).show();
  30.         // When returning 'true', default Backendless onMessage implementation
  31.         // will be executed. The default implementation displays the notification
  32.         // in the Android Notification Center. Returning false, cancels the
  33.         // execution of the default implementation.
  34.         return false;
  35.     }
  36.  
  37.     @Override
  38.     public void onError(Context context, String message) {
  39.         Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement