Skip to content

Commit

Permalink
Update firebase integration to be based on latest demo app
Browse files Browse the repository at this point in the history
  • Loading branch information
3noch committed Jul 20, 2020
1 parent 719f551 commit 40fe4f9
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 30 deletions.
1 change: 0 additions & 1 deletion android-activity.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ category: Mobile
build-type: Simple
extra-source-files:
java/systems/obsidian/HaskellActivity.java
java/systems/obsidian/LocalFirebaseInstanceIDService.java
java/systems/obsidian/LocalFirebaseMessagingService.java
cabal-version: >=1.10

Expand Down
2 changes: 1 addition & 1 deletion cbits/HaskellActivity.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ JNIEXPORT void JNICALL Java_systems_obsidian_HaskellActivity_haskellOnNewIntent
}
}

JNIEXPORT void JNICALL Java_systems_obsidian_LocalFirebaseInstanceIDService_handleDeviceToken (JNIEnv *env, jobject thisObj, jstring token) {
JNIEXPORT void JNICALL Java_systems_obsidian_LocalFirebaseMessagingService_handleDeviceToken (JNIEnv *env, jobject thisObj, jstring token) {
if(gCallbacks && gCallbacks->firebaseInstanceIdService_sendRegistrationToServer) {
const char *cstring_token = (*env)->GetStringUTFChars(env, token, 0);
gCallbacks->firebaseInstanceIdService_sendRegistrationToServer(cstring_token);
Expand Down
28 changes: 0 additions & 28 deletions java/systems/obsidian/LocalFirebaseInstanceIDService.java

This file was deleted.

20 changes: 20 additions & 0 deletions java/systems/obsidian/LocalFirebaseMessagingService.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// File based on https://github.com/firebase/quickstart-android/blob/d454ecdbb664450d11812b9cfde91fca36c56a81/messaging/app/src/main/java/com/google/firebase/quickstart/fcm/java/MyFirebaseMessagingService.java
package systems.obsidian;

import android.util.Log;
Expand All @@ -6,7 +7,26 @@

public class LocalFirebaseMessagingService extends FirebaseMessagingService {

private static final String TAG = "LocalFirebaseMessagingService";

private native void handleDeviceToken(String token);
private native void handleNotification(String intent, String notificationdata);

/**
* Called if InstanceID token is updated. This may occur if the security of
* the previous token had been compromised. Note that this is called when the InstanceID token
* is initially generated so this is where you would retrieve the token.
*/
@Override
public void onNewToken(String token) {
Log.d(TAG, "onNewToken: Refreshed token: " + token);

// 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.
handleDeviceToken(token);
}

@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
if (remoteMessage.getData().size() > 0) {
Expand Down

0 comments on commit 40fe4f9

Please sign in to comment.