Implement Facebook notifications and invitations
We should allow an additional endpoint in streams_rule to "deliver" notifications. In addition to mobile numbers and email addresses, if a user has authenticated with facebook, they have an fb_uid and our app can deliver notifications to that user.
https://developers.facebook.com/docs/games/notifications "Apps can send notifications to people who have authorized the app. No special or extended permission is required."
Facebook will not deliver notifications to non-app users. However, we also want to implement an invitation system, and it can't work exactly analogously to invitations over SMS and Email, since those systems DO deliver to non-app users. Here's how it can work:
A user can share a link to someplace in our app. Our app can provide the user with this link, along with an "invite token". However, in the database, the userId field of streams_invite and streams_invited tables will be blank, and we won't create a future user. When the first visitor to this link authenticates with facebook, we create an account for them the usual way (i.e. linked to fb_uid). We request the user_friends permission by default, so we can check if the invited user is a facebook friend of the inviting user using https://developers.facebook.com/docs/graph-api/reference/v2.2/user/friends
If they are indeed friends, then we can use the invite with blank userId as a template and go through the motions of simulating an invite being sent to this "future user" that in fact just registered, and then accepted. The code paths entered should be exactly the same ones that are used for actually sending the invites and accepting them (but which don't deliver any notifications via fb_uid to the invited user). These code paths do things such as adding contacts with the label Streams/invited' andStreams/invitedBy`, and can have other hooks besides.
Note that Users::saveContactsFromLinks won't really do anything for facebook contacts, since facebook no longer lets apps get the full list of friends and import it, like an address book. In addition, we have no idea which facebook friends the user meant to invite -- maybe they just posted the link on their wall. Unlike SMS, we can't spend specific messages directly to the non-app invited users, because facebook doesn't allow that.
However, we could notify people when any of their facebook friends have verified their fb_uid with the app. That should probably be done after issue #7 , and integrated with that system and its code paths.