mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-04-14 11:46:32 +00:00
Added firebase notifications
This commit is contained in:
parent
2ddc426d6b
commit
3595f6d460
6 changed files with 64 additions and 0 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -54,3 +54,4 @@ fabric.properties
|
|||
Habitica/res/values/secret_strings.xml
|
||||
habitica.properties
|
||||
habitica.resources
|
||||
Habitica/google-services.json
|
||||
|
|
|
|||
|
|
@ -128,6 +128,20 @@
|
|||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
|
||||
<service
|
||||
android:name=".helpers.notifications.HabiticaFirebaseMessagingService">
|
||||
<intent-filter>
|
||||
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
|
||||
</intent-filter>
|
||||
</service>
|
||||
<service
|
||||
android:name=".helpers.notifications.HabiticaFirebaseInstanceIDService">
|
||||
<intent-filter>
|
||||
<action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
|
||||
</intent-filter>
|
||||
</service>
|
||||
|
||||
<provider
|
||||
android:name="android.support.v4.content.FileProvider"
|
||||
android:authorities="com.habitrpg.android.habitica.fileprovider"
|
||||
|
|
|
|||
|
|
@ -140,6 +140,10 @@ dependencies {
|
|||
//Leak Detection
|
||||
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.3.1'
|
||||
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.3.1'
|
||||
|
||||
//Push Notifications
|
||||
compile 'com.google.firebase:firebase-core:9.0.2'
|
||||
compile 'com.google.firebase:firebase-messaging:9.0.2'
|
||||
}
|
||||
|
||||
android {
|
||||
|
|
@ -276,3 +280,4 @@ apply plugin: 'com.getkeepsafe.dexcount'
|
|||
apply plugin: 'com.android.application' //or apply plugin: 'java'
|
||||
apply plugin: 'me.tatarka.retrolambda'
|
||||
apply plugin: 'com.jakewharton.hugo'
|
||||
apply plugin: 'com.google.gms.google-services'
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
package com.habitrpg.android.habitica.helpers.notifications;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.google.firebase.iid.FirebaseInstanceId;
|
||||
import com.google.firebase.iid.FirebaseInstanceIdService;
|
||||
|
||||
/**
|
||||
* Created by keithholliday on 6/24/16.
|
||||
*/
|
||||
public class HabiticaFirebaseInstanceIDService extends FirebaseInstanceIdService {
|
||||
@Override
|
||||
public void onTokenRefresh() {
|
||||
// Get updated InstanceID token.
|
||||
String refreshedToken = FirebaseInstanceId.getInstance().getToken();
|
||||
Log.d("test", "Refreshed token: " + refreshedToken);
|
||||
|
||||
// TODO: Implement this method to send any registration to your app's servers.
|
||||
// sendRegistrationToServer(refreshedToken);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package com.habitrpg.android.habitica.helpers.notifications;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.google.firebase.messaging.FirebaseMessagingService;
|
||||
import com.google.firebase.messaging.RemoteMessage;
|
||||
|
||||
/**
|
||||
* Created by keithholliday on 6/24/16.
|
||||
*/
|
||||
public class HabiticaFirebaseMessagingService extends FirebaseMessagingService {
|
||||
@Override
|
||||
public void onMessageReceived(RemoteMessage remoteMessage) {
|
||||
// TODO(developer): Handle FCM messages here.
|
||||
// If the application is in the foreground handle both data and notification messages here.
|
||||
// Also if you intend on generating your own notifications as a result of a received FCM
|
||||
// message, here is where that should be initiated. See sendNotification method below.
|
||||
Log.d("test", "From: " + remoteMessage.getFrom());
|
||||
Log.d("test", "Notification Message Body: " + remoteMessage.getNotification().getBody());
|
||||
}
|
||||
}
|
||||
|
|
@ -8,6 +8,7 @@ buildscript {
|
|||
classpath 'com.android.tools.build:gradle:2.1.2'
|
||||
classpath 'com.android.databinding:dataBinder:1.0-rc4'
|
||||
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
|
||||
classpath 'com.google.gms:google-services:3.0.0'
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue