git-point icon indicating copy to clipboard operation
git-point copied to clipboard

Add push notifications for watched repos

Open andrewda opened this issue 7 years ago • 17 comments

It would be awesome to get push notifications for my watched repos. This is something that all other GitHub apps either don't have or are a paid feature.

I could definitely work on at least the iOS push notifications, though Android doesn't seem to be much different.

This might help: https://medium.com/differential/how-to-setup-push-notifications-in-react-native-ios-android-30ea0131355e

andrewda avatar Jul 17 '17 21:07 andrewda

I think this is an outstanding idea, please feel free to go ahead trying it with iOS. I can (or anybody else with Android) will be happy to help with Android if they happen to be different.

So push notifications for watched repos is a great start. Definitely worth exploring push notifications for other things (such as a user has followed you for example) and then eventually allowing the user to change which notifications they get. Of course this is just cherries on top, definitely worth getting watched repo notifications up and running first.

housseindjirdeh avatar Jul 17 '17 22:07 housseindjirdeh

Best way to go about this IMO is to poll each user's notifications feed every ~2 minutes and send any new notifications to OneSignal. Tell me if anyone has any better ideas tho!

andrewda avatar Jul 27 '17 17:07 andrewda

Just contacted GitHub about the possibility of adding webhooks for users as that would make this all a lot easier.

Edit: wow they got back to me quickly, here's their reply:

Hi Andrew,

Thanks for getting in touch! We've passed your request to the team working on webhooks internally for consideration, though we can't make any promises. Let us know if you have any other ideas!

They also pointed me towards using Conditional Requests if we do go down the polling avenue: https://developer.github.com/v3/#conditional-requests

andrewda avatar Jul 27 '17 18:07 andrewda

Something else I'm looking into is setting up Firebase Cloud Function on a 2-5 minute cron job. We get 125,000 calls/month for free, which would be 2.89 calls/minute. We also have only 540 seconds to complete the call before it gets forcefully terminated.

Here's my thinking for the flow of how this would work:

  1. User enables push notifications in settings.
    1. Username and FCM token are saved to Firebase.
    2. In addition, one of the following is stored (still need to decide on which one makes more sense):
      1. The user's private RSS feed (https://github.com/andrewda.private.atom?token=abc123).
      2. The user's access token for use with the notification feed API.
  2. Cron job polls ever 2 minutes for new notifications.
    1. If need be, we can create several cron jobs that split up the work. First job takes users 1-10, second job takes users 11-20, third job takes 21-30.
  3. Cron job sends push notification (using the FCM token saved above) whenever it finds a new notification.

I think this is the best we can do until GitHub adds user event webhooks.

andrewda avatar Jul 28 '17 20:07 andrewda

That sounds amazing @andrewda 🙌 I'm always impressed with how much Firebase provides for free. Even though costs can get steep with priced plans, they always have awesome free starting points. Appreciate you looking into this.

Couple of things I'm curious about:

    1. What's an FCM token? (forgive me if this is a foolish question :P)
    2. Yep definitely something we need to decide. If the user's private RSS feed will work that might definitely be a more secure route - storing the user's access token can definitely bring up some security concerns (and it's something we'll need to declare ino ur privacy policy). We'll definitely chat about this.
  1. For 2 & 3 I like the sound of that 👍

housseindjirdeh avatar Jul 28 '17 20:07 housseindjirdeh

  • FCM token = Firebase Cloud Messaging token - it identifies the user so we can send that specific user notifications in the future.
  • Totally agree about the RSS feed. The only problem with it is that we would have to parse the RSS and decide what notifications to send to the user ourselves, as opposed to just going off of what the user already gets notifications about in their notification feed.

andrewda avatar Jul 28 '17 21:07 andrewda

Hmm you're right it very well might be easier to leverage the user's access token in that case - let's decide at that point if storing the user token in a secure server is a viable option

housseindjirdeh avatar Jul 29 '17 01:07 housseindjirdeh

It's also completely up to the user whether their token would be stored, and we would make it clear that the token would be immediately when the user disables push notifications.

andrewda avatar Jul 29 '17 03:07 andrewda

Is there a way that we can get a separate token with only the notification reading scope? I think it would be fine if that only required another sign in from the user.

andrewda avatar Jul 29 '17 03:07 andrewda

I think that's a great idea. We may be able to leverage Basic Auth specifically creating a scope for notification and then clearing it when they disable again. If this happens to require an additional sign in, I'm okay with that as long as we briefly explain to the user why it's necessary (for improved security and so forth)

housseindjirdeh avatar Jul 29 '17 16:07 housseindjirdeh

This feature would be golden! 🥇

henrikra avatar Aug 06 '17 08:08 henrikra

Any update on this feature? Would love it implemented within the app

coderste avatar Nov 17 '17 17:11 coderste

Hallo @housseindjirdeh and @andrewda , I am using GitPoint for a few weeks now and it's a pleasure to work with this app! Is there any update on this push notification feature? Have to agree with @henrikra: it would be golden! =:-)

jcgerhard avatar Mar 16 '18 12:03 jcgerhard

Me too! Initially, I thought I had missed out on some setting but only later realized that push notifications are not a feature of the app yet. Any updates? It would be awesome!

jeeejay avatar Aug 14 '18 17:08 jeeejay

Unfortunately I've been busy lately and have been away from the project for a while, but I'm looking to get back into GitPoint soon and will continue looking into a way to make notifications work!

andrewda avatar Aug 14 '18 22:08 andrewda

Same here, I've been a bit occupied this past while unfortunately and most of the maintainers have :(

But I'm also looking to get back into the swing of things in the coming weeks. If this is a priority, I can work on this first as well :)

housseindjirdeh avatar Sep 07 '18 03:09 housseindjirdeh

I just read this article, and I wonder if we could do something similar to send push notifications?

https://towardsdatascience.com/using-gitlabs-ci-for-periodic-data-mining-b3cc314ecd85

andrewda avatar Apr 15 '19 15:04 andrewda