Skip to content

Instantly share code, notes, and snippets.

@hynra
Created November 2, 2017 17:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hynra/2cecbd70cac198f38bae6663c9ec74ba to your computer and use it in GitHub Desktop.
Save hynra/2cecbd70cac198f38bae6663c9ec74ba to your computer and use it in GitHub Desktop.
// Java
public class FirebaseInstanceIDService extends FirebaseInstanceIdService {
private final String TAG = this.getClass().getSimpleName();
private Context context;
@Override
public void onTokenRefresh() {
String refreshedToken = FirebaseInstanceId.getInstance().getToken();
sendTokenToServer(refreshedToken);
}
private void sendTokenToServer(String token) {
// kirim token ke backend, etc.
}
}
// manifest
<service android:name=".services.FirebaseInstanceIDService">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
</intent-filter>
</service>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment