Commit Graph

530 Commits

Author SHA1 Message Date
Chris Bianca 88b1cad8c4 [android][notifications] Change actions `runInBackground` to use `showUserInterface` instead 2018-05-18 08:26:16 +01:00
Dariusz Luksza 17f7f39dac Implement handling of Android actions in background
There are some cases when local notification action should be handled in
background eg. snoozing the reminder. In case of it launching app UI is
not necessary and would be confusing for the end user.

Therefore there should be a way to handle local notification action in
background.

For this reason new property 'runInBackground' was added to the
AndroidAction class and TypeScript type.

Also new broadcast receiver and service were implemented to handle
properly background actions.

In order to run particular action in background API consumer need to set its
'runInBackground' property to 'true', eg:

  ...
  .android.addAction(new firebase.notifications.Android.Action("snooze",
  "ic_snooze", "Snooze").setRunInBackground(true))
  ...

Then, there are two cases that API consumer needs to handle.

First when app is in the foreground, standard notification and
notification action code path will be executed. This mean, that:
 * onNotification() listener will be called (which should call
 displayNotification(), in order to show it to the user),
 * onNotificationOpen() listener will be called after the action is
 tapped by the user

Secondly, when application is in background or it is not running new
'RNFirebaseBackgroundNotificationAction' handler will be called. To
properly handle this case API consumer should create a background
asynchronous handler:

  const handleAsyncTask = async (notificationOpen: NotifficationOpen) => {
    if (notificationOpen && notificationOpen.notification) {
      const action = notificationOpen.action;
      const notificationId = notificationOpen.notification.notificationId;
      if (action === "snooze") {
        console.log("Reschedule notification for later time", notificationId);
      } else {
        console.log("unsupported action", action);
      }
      // hide the notification
      firebase.notifications().removeDeliveredNotification(notificationId);
    }
  }

Next hander should be registered to headless handler:

  AppRegistry.registerHeadlessTask('RNFirebaseBackgroundNotificationAction', () => handleAsyncTask);

Finally AndroidManifest.xml file must be modified, to include receiver
and service definition:

  <receiver
      android:name="io.invertase.firebase.notifications.RNFirebaseBackgroundNotificationActionReceiver"
      android:exported="true">
    <intent-filter>
      <action android:name="io.invertase.firebase.notifications.BackgroundAction"/>
    </intent-filter>
  </receiver>
  <service android:name="io.invertase.firebase.notifications.RNFirebaseBackgroundNotificationActionsService"/>

Now when ever 'Snooze' action is pressed it will launch
'handleAsyncTask' function in the background or onNotificationOpen()
when app is in foreground. And reschedule the notification
for the later time.
2018-05-16 08:20:24 +02:00
Dariusz Luksza 57901cd29a Add Android API to delete channel and channel group 2018-05-14 09:24:44 +02:00
Salakar 93d4d7d674 [types][auth] add sendSignInLinkToEmail, signInWithEmailLink & isSignInWithEmailLink types and update EmailAuthProvider types 2018-05-13 00:48:57 +01:00
Salakar 59b406e8ed [js][auth] add signInWithEmailLink method + tweak isSignInWithEmailLink 2018-05-13 00:09:00 +01:00
Salakar 1240e6cd93 [js][auth] update firebase.auth.EmailAuthProvider to support link credentials 2018-05-12 23:33:16 +01:00
Salakar b98276c2a5 [js][auth] add isSignInWithEmailLink method 2018-05-12 23:27:05 +01:00
Salakar 56ffaac06b [js][auth] add sendSignInLinkToEmail method 2018-05-12 23:21:39 +01:00
Salakar cf25ba23e5 [both][auth] Deprecated firebase.auth().fetchProvidersForEmail in favor of firebase.auth().fetchSignInMethodsForEmail() 2018-05-12 22:51:42 +01:00
Chris Bianca 25506479d3 [firestore][android] Add support for firestore v16 2018-05-08 15:36:49 +01:00
Salakar ef33a7cb2a [ts][typings][functions] add type defs 2018-05-07 19:49:34 +01:00
Salakar 6040136a15 [js][functions] move errorOrResult fn outside class 2018-05-07 19:32:20 +01:00
Salakar d26f7a17ad [js][functions] misc HttpsError 2018-05-06 13:50:39 +01:00
Salakar e5233c9af3 Merge branch 'master' of https://github.com/invertase/react-native-firebase into functions 2018-05-06 00:55:37 +01:00
Salakar d06fbec40a [js][functions] finalise + cleanup 2018-05-06 00:50:09 +01:00
Salakar 30f23316c4 [core] add functions module to core + types 2018-05-05 19:25:52 +01:00
Salakar 368b3ad068 [functions][android][js] implementation - wip 2018-05-04 16:33:59 +01:00
Chris Bianca ff41a45fdd [firestore][types] Add Typescript types for Blob 2018-05-04 16:30:32 +01:00
Chris Bianca 5f21ddc0fc
Merge pull request #1050 from TaopaiC/remote-input-alloweddatatypes
fix allowedDataTypes in fromNativeAndroidRemoteInput
2018-05-04 16:23:20 +01:00
Salakar 8dee086f1f [functions][js] start of functions implementationn 2018-05-04 08:37:30 +01:00
Salakar 374c617672 [internals][js] move Base64 util to shared utils 2018-05-03 21:54:45 +01:00
Salakar d493e00a67 [firestore][js] additional Blob class input arg validations 2018-05-03 21:50:53 +01:00
Salakar 9c49d9ef57 [firestore][js] implement Blob support 2018-05-03 20:13:51 +01:00
Salakar d180b40d19 [firestore][js] blob uint8 coversion + blob comparator 2018-05-02 10:05:30 +01:00
Salakar ff3b0fd7ea [firestore][js] start of blob support 2018-05-01 22:20:55 +01:00
TaopaiC 5f7edf668c fix allowedDataTypes in fromNativeAndroidRemoteInput 2018-05-01 23:45:55 +08:00
Chris Bianca 7cc7d5afe5 [auth] Fix possible race condition #980 2018-04-26 09:21:10 +01:00
Adam Michel ea8e106129
Use union type for `fieldPath` option to query `orderBy` and `where` functions.
Constructing and passing a FieldPath object to the `orderBy` or `where` functions of a Firestore query currently raises a type error since those functions are only typed to expect a `string` value. This fixes that since those functions do accept FieldPath object types as well as astrings.
2018-04-24 12:46:23 -07:00
Salakar d0b6972e39 [database][js] fixed a regression where snapshot.child() would no longer work on array values 2018-04-22 00:29:33 +01:00
Salakar 0a828aae40 [firestore][js] fix issue with parent() incorrectly returning a 'parent' Path on a root level Path 2018-04-22 00:25:36 +01:00
Sibelius Seraphini 3ca951184f
feat(flow): prefer string over String 2018-04-19 12:01:40 -03:00
Salakar f4832410bb [firestore] .settings() - use hasOwnProperty instead of truthy value existence checks 2018-04-16 18:20:08 +01:00
Salakar 88410b409a [firestore] fix incomplete transaction error stack 2018-04-16 17:39:29 +01:00
Salakar 317b02b901 [firestore] Path - remove unreachable code paths 2018-04-16 16:21:24 +01:00
Salakar b534e02016 [firestore] added missing conditional for firestore transaction errors - should now error on failed promise validations 2018-04-16 16:20:33 +01:00
Salakar 5589ed7f4f [database] fix flow issue 2018-04-16 10:11:18 +01:00
Chris Bianca c275e02fcc [types] Fix typescript issues 2018-04-16 08:14:30 +01:00
Salakar 2a1e365231 fix flow issue #978 2018-04-13 22:37:48 +01:00
Chris Bianca 3a5686c226 [ios][notifications] Handle messaging token refreshed before bridge initialised #960 2018-04-13 14:23:55 +01:00
Salakar c14e60017e [firestore][DocumentSnapshot] explicitly bind context on data/get methods to keep context during destructuring (includes tests) 2018-04-13 11:50:30 +01:00
Chris Bianca b0abf23c6d [firestore] Add support for settings 2018-04-13 09:58:53 +01:00
Chris Bianca 1922a25198 [firestore] Add setLogLevel support 2018-04-13 08:41:57 +01:00
Chris Bianca c27918c53c [types] Add missing constructors 2018-04-13 08:41:57 +01:00
Salakar b918eea630 [firestore] add support for `DocumentSnapshot.get('dot.notated.field.path')` 2018-04-12 12:38:28 +01:00
Salakar f1e9d28869 [firestore] add support for `DocumentSnapshot.get('dot.notated.field.path')` 2018-04-12 12:30:41 +01:00
Chris Bianca 590d69ce89 [types] Add missing typescript statics for messaging, notifications and links 2018-04-12 08:50:13 +01:00
Chris Bianca 0645d179b3 [notifications] Make title and body optional fields 2018-04-11 18:15:38 +01:00
Michele Bombardi 3d80395c82 typings 2018-04-08 11:46:41 +02:00
Chris Bianca b21e7d0eab [crashlytics] Move to top level crashlytics namespace 2018-04-03 16:51:05 +01:00
Chris Bianca f5fa7436a9 [notifications] Add enableLights and enableVibration to AndroidChannel 2018-03-31 15:42:14 +01:00