-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMyFirebaseInstanceIdService.java
More file actions
36 lines (25 loc) · 1.03 KB
/
Copy pathMyFirebaseInstanceIdService.java
File metadata and controls
36 lines (25 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package com.example.fcm.fcmdemo;
import android.content.Intent;
import android.util.Log;
import com.google.firebase.iid.FirebaseInstanceId;
import com.google.firebase.iid.FirebaseInstanceIdService;
/**
* Created by Administrator on 5/24/2017.
*/
public class MyFirebaseInstanceIdService extends FirebaseInstanceIdService {
public static final String br = "brc";
@Override
public void onTokenRefresh() {
// Get updated InstanceID token.
String refreshedToken = FirebaseInstanceId.getInstance().getToken();
Log.d("TAG", "Refreshed token: " + refreshedToken);
// If you want to send messages to this application instance or
// manage this apps subscriptions on the server side, send the
// Instance ID token to your app server.
getApplicationContext().sendBroadcast(new Intent(br));
storeToken(refreshedToken);
}
private void storeToken(String refreshedToken) {
SharedPrefManager.getInstance(getApplicationContext()).storeToken(refreshedToken);
}
}