Skip to content

Instantly share code, notes, and snippets.

@amadeu01
Created June 27, 2018 19:21
Show Gist options
  • Save amadeu01/c7c78400b1ce1774c3263ce45c340d1d to your computer and use it in GitHub Desktop.
Save amadeu01/c7c78400b1ce1774c3263ce45c340d1d to your computer and use it in GitHub Desktop.
public class FirebaseMessagingService extends com.google.firebase.messaging.FirebaseMessagingService {
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
super.onMessageReceived(remoteMessage);
try {
if (remoteMessage.getData().size() > 0) {
// do stuff.....
}
if (remoteMessage.getNotification() != null) {
Timber.d("Message Notification Body: %s", remoteMessage.getNotification().getBody());
}
} catch (Exception exception) {
Timber.e(exception);
}
}
}
@amadeu01
Copy link
Author

Não esquece de colocar no Manifest

         <service android:name=".services.FirebaseMessagingService">
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT" />
            </intent-filter>
        </service>
        <service android:name=".services.FirebaseMessagingHelper">
            <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