Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fetch messages in background when Push Notification is received #3451

Closed
yenda opened this issue Feb 26, 2018 · 13 comments
Closed

Fetch messages in background when Push Notification is received #3451

yenda opened this issue Feb 26, 2018 · 13 comments
Labels

Comments

@yenda
Copy link
Contributor

yenda commented Feb 26, 2018

User Story

  • As a user, I expect to see the unread messages in the when I click the push notification. Currently, I have to wait for sync to kick in and retrieve the messages from the network.
  • As a Status contributor, I want to have a better sense of what the Sent/Received ratio is. If the user doesn't open the app for 24h after receiving a message, that message will never be counted as received, which is fake news!

Description

Type: Features

Summary:

The application could run in the background upon reception of a notification to fetch recent messages, decrypt them and consequently send the signal to Mixpanel.

Expected behavior

  1. User receives message and PN;
  2. User loses internet connectivity;
  3. After a minute, user clicks on PN;
  4. App opens and message is ready to be read.

Actual behavior

  1. User receives message and PN;
  2. User loses internet connectivity;
  3. After a minute, user clicks on PN;
  4. App opens and message doesn't appear until foreground sync has completed.

Solution

Summary:
It could be done using background app refresh feature on iOS which allows an app to wake up for 30 sec in the background upon reception of a notification

When a background update notification is delivered to the user's device, iOS wakes up your app in the background and gives it up to 30 seconds to run. In iOS, the system delivers background update notifications by calling the application:didReceiveRemoteNotification:fetchCompletionHandler: method of your app delegate. Use that method to initiate any download operations needed to fetch new data. Processing remote notifications in the background requires that you add the appropriate background modes to your app.

Similar feature should exist on Android.

  1. The notification sent by the client should be a data-only notification, otherwise, it will only call app-specific code when it is tapped by the receiver or the app is in the foreground.
  2. Upon getting called onMessageReceived() (Android)/didReceiveRemoteNotification() (iOS), the app should trigger a network sync to retrieve messages, in a platform-specific way that allows for long-running tasks, and create a local notification.
@pedropombeiro
Copy link
Contributor

Looking at the Firebase docs, this could be achieved by sending a collapsible message, containing either simply data, or perhaps a hybrid (data + notification). It would work on both iOS and Android.

@pedropombeiro
Copy link
Contributor

pedropombeiro commented Apr 23, 2018

This GHI could be improved #2869 so it can still access the messages after the app is suspended. Otherwise the app will only be able to retrieve messages if the app hasn't yet been terminated/suspended by the OS.

@ghost
Copy link

ghost commented Dec 6, 2018

This issue has been automatically closed. Please re-open if this issue is important to you.

@ghost ghost closed this as completed Dec 6, 2018
@pedropombeiro
Copy link
Contributor

The level of effort required to implement this issue has gone down with #6893 which already implements local notifications. status-im/notifications/handle-on-message is already being called when a PN arrives in order to display a local PN, so we could kick off message fetching from here if the db is unlocked.

@StatusSceptre
Copy link
Member

@pombeirp Should we still implement this as a bounty?

@pedropombeiro
Copy link
Contributor

@StatusSceptre Yes, I believe it makes sense.

@gitcoinbot
Copy link

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


This issue now has a funding of 180.0 DAI (180.0 USD @ $1.0/DAI) attached to it as part of the Status-im fund.

@pedropombeiro
Copy link
Contributor

pedropombeiro commented Jan 31, 2019

@dhamaniasad are you working on this? I was looking at the issue description, and quite a bit has changed since it was initially written, namely we now don't use notifications but instead data-only notifications, so in the case of iOS, if the app isn't running it won't be invoked by the OS to notify it of a new PN (that is an issue we're looking into as well).

I happened to be working in this area of the code earlier today and noticed it would be a quick win to trigger the fetching of messages (working only on Android, and as long as the user is signed in). Forgot about this existing bounty :-( Sorry about that @dhamaniasad. Would be cool if you could solve the iOS background sync issue though.

@dhamaniasad
Copy link
Contributor

@pombeirp No worries, I hadn't realized when I applied for the bounty that this is not a regular React Native project but that in fact it uses Clojure. So I don't think I'd be able to solve the issue right now anyway. I'll remove myself from the issue on Gitcoin.

But it'd be cool if you can look at #7398, a PR I made for another bounty.

@StatusSceptre
Copy link
Member

@pombeirp and @yenda do we still want this as an open bounty? It's been 3 months since he relesed himself from it.

@pedropombeiro
Copy link
Contributor

I believe this has since been implemented elsewhere, so we can close the issue.

@gitcoinbot
Copy link

Issue Status: 1. Open 2. Cancelled


The funding of 180.0 DAI (180.0 USD @ $1.0/DAI) attached to this issue has been cancelled by the bounty submitter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

9 participants