Commit Graph

1894 Commits

Author SHA1 Message Date
Michael Diarmid bee7c7851f
Merge pull request #1195 from EvanBacon/@evanbacon/thread-deadlock-bug
Fixed Deadlock
2018-06-08 23:48:23 +01:00
Evan Bacon cca3c13d2d Fixed Deadlock
Running this in a detached expo app can sometimes deadlock from thread issues.
I've replaced `dispatch_sync(dispatch_get_main_queue(), ^{});`  with `RCTUnsafeExecuteOnMainQueueSync(^{});` to fix this.

I only hit the error in the `RNFirebaseStorage.m` but it seems like the `RNFirebaseAnalytics.m` and `RNFirebase.m` modules could also have this same issue.

`RCTUnsafeExecuteOnMainQueueSync` checks to see if the method is being executed on the main thread before trying to sync to the main thread. If you try to sync on the main thread whilst on the main thread, you hit a deadlock.

You can read more about it here: https://stackoverflow.com/questions/12379059/why-is-this-dispatch-sync-call-freezing?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa

The only testing I did was in a seperate detached ExpoKit project. Running this function would cause the crash.
```js
await firebase
      .storage()
      .ref(uploadUri)
      .putFile(uri);
```
2018-06-08 14:44:48 -07:00
Chris Bianca 2a083f7deb [android][notifications] Fix for #1167 - progress bar not working 2018-06-03 17:32:40 +04:00
Chris Bianca bc0326b3bf
Merge pull request #1113 from judemanutd/patch-2
Resolve display notification promise
2018-05-22 16:52:31 +01:00
Jude Fernandes 6e095be2bf
Resolve display notification promise
Once the notification is created the promise was not being resolved so in a situation where the user is waiting on the promise to complete, they would not get a callback and in case a user used async/await this would cause the app to get stuck at that point.
2018-05-22 01:20:52 +05:30
Chris Bianca 130321a27f 4.2.0 2018-05-18 08:54:42 +01:00
Chris Bianca 88b1cad8c4 [android][notifications] Change actions `runInBackground` to use `showUserInterface` instead 2018-05-18 08:26:16 +01:00
Chris Bianca 7b81731239 Update README.md versions 2018-05-18 08:01:40 +01:00
Chris Bianca 1f814d4cab [android][firestore] Ensure settings are preserved if `settings` is called multiple times 2018-05-18 07:58:32 +01:00
Michael Diarmid 4a362bd786
Update README.md 2018-05-17 09:57:56 +01:00
Michael Diarmid e8ed28de4c
Update README.md 2018-05-17 09:56:31 +01:00
Chris Bianca 92fa2f102a [ios][messaging] Clear pending messages once sent to JS 2018-05-17 08:27:23 +01:00
Chris Bianca dc793696fe [ios] Cache and then send data messages received whilst app is being initialised #1005 2018-05-16 17:37:58 +01:00
Chris Bianca 42e7fb2e5d [ios] Firebase iOS v5 support 2018-05-16 17:22:47 +01:00
Chris Bianca 34c0878098 [auth] Support email link in checkActionCode 2018-05-16 12:41:48 +01:00
Chris Bianca 35474462c6 [ios][firestore] Ensure that firestore uses the separate dispatch queue for callbacks 2018-05-16 12:11:55 +01:00
Chris Bianca 640d7aa7ae
Merge pull request #1074 from dluksza/android-notification-action-background-handler
Implement handling of Android actions in background
2018-05-16 10:39:18 +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
Chris Bianca fa9bac1a72 [ios] Set separate dispatch queues for firestore and database 2018-05-15 10:02:18 +01:00
Chris Bianca 54f41565db [misc] Update pods for tests and bridge 2018-05-15 10:01:52 +01:00
Michael Diarmid 7fb3e1464e
Merge pull request #1088 from pranjal-jain/fix-cancel-notification
[Android] [Notifications] Fix cancel notification promise
2018-05-15 00:23:26 +01:00
Pranjal Jain 4efb0c4dcf fix(notifications): Resolve promise on after notification is cancelled 2018-05-15 01:57:03 +05:30
Chris Bianca e68118e049
Merge pull request #1080 from dluksza/android-delete-channel
Add Android API to delete channel and channel group
2018-05-14 11:02:15 +01:00
Dariusz Luksza 57901cd29a Add Android API to delete channel and channel group 2018-05-14 09:24:44 +02:00
Salakar bcd655d765 Merge remote-tracking branch 'origin/master' 2018-05-13 18:31:37 +01:00
Salakar 061a60a106 [tests][storage] migrate and re-write legacy tests 2018-05-13 18:30:04 +01:00
Salakar 9112d4beff [tests][helpers] add Promise.defer() helper 2018-05-13 18:29:34 +01:00
Michael Diarmid 25c8677076
Update README.md 2018-05-13 08:59:54 +01:00
Salakar 6356360210 [tests][android] misc build 2018-05-13 01:36:02 +01:00
Salakar 0262bdfa0b [android] update package rnpm config to use `implementation` 2018-05-13 01:35:44 +01:00
Salakar 187c756550 [tests][auth] isSignInWithEmailLink tests 2018-05-13 01:00:30 +01:00
Salakar 93d4d7d674 [types][auth] add sendSignInLinkToEmail, signInWithEmailLink & isSignInWithEmailLink types and update EmailAuthProvider types 2018-05-13 00:48:57 +01:00
Salakar 98fb88a882 [tests][auth] misc email auth tests 2018-05-13 00:37:47 +01:00
Salakar d0ae75d531 [ios][auth] add signInWithEmailLink native method 2018-05-13 00:37:19 +01:00
Salakar 4a6f12ec59 [android][auth] add signInWithEmailLink native method 2018-05-13 00:36:22 +01:00
Salakar 59b406e8ed [js][auth] add signInWithEmailLink method + tweak isSignInWithEmailLink 2018-05-13 00:09:00 +01:00
Salakar 3cba1c4e62 [tests][auth] add tests for new EmailAuthProvider properties & methods 2018-05-12 23:36:57 +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 de33d97be9 [ios][auth] add sendSignInLinkToEmail native method 2018-05-12 23:14:06 +01:00
Salakar 15992f3ba9 [android][auth] add sendSignInLinkToEmail native method 2018-05-12 23:13:54 +01:00
Salakar 45bea847b4 [ios][auth] add `emailLink` support for internal getCredentialForProvider util 2018-05-12 22:58:47 +01:00
Salakar f81e50ccb8 [android][auth] add `emailLink` support for internal getCredentialForProvider util 2018-05-12 22:58:35 +01:00
Salakar cf25ba23e5 [both][auth] Deprecated firebase.auth().fetchProvidersForEmail in favor of firebase.auth().fetchSignInMethodsForEmail() 2018-05-12 22:51:42 +01:00
Salakar efc73163a5 [auth][android] import cleanup 2018-05-12 22:16:20 +01:00
Salakar a064d7dd2a [auth][android] update getJSError to handle 'INVALID_IDENTIFIER' - return from fetchSignInMethodsForEmail for example if email is invalid (not a standard auth exception, it's a grpc one it seems) 2018-05-12 22:15:23 +01:00
Salakar c185b3b060 [auth][android] update getJSError util regex to allow extracting codes from http errors - fixes #934 2018-05-12 22:11:50 +01:00
Salakar f13a2b5f9c [auth][android] replace deprecated task fetchProvidersForEmail with fetchSignInMethodsForEmail task + misc linting and legacy utils cleanup 2018-05-12 22:08:11 +01:00
Salakar e45db1a465 [tests][android] update to latest dependencies + fix build issues 2018-05-12 21:16:40 +01:00