The community forums are in BETA and closed to the public.

Building an app around Facebook friends

I am building an app which uses Facebook login to fetch all friends. When I post an update, all my FB friends should get notified. How do I achieve this in PubNub APIs. I am looking at PNChannel

 PNChannel *myChannel = [PNChannel channelWithName:myFBID shouldObservePresence:YES];
 [PubNub subscribeOnChannel:myChannel];
 [PubNub sendMessage:myMessage toChannel:myChannel];

So if I have 200 users for my App, I will have 200 channels in total. Is this the right way to solve it ? Or there is any better way. Thanks in advance.

At a high level, this is what you should do.

Private Inbound Channels

  • Each user gets their own private inbound channel (chinbounduser1) and subscribes to their own inbound channel.
  • Friends (users granted access to others' inbound channels) can publish private messages to each other using these inbound channels. For example, user1 sends a message to user2 on chinbounduser2 and user2 sends messages to user1 on chinbounduser1.
  • Other friends may also post private messages on these same channels so you need to provide a "sender id" in the message payload so you know who sent the message and which channel to reply on.

Public Outbound Channels

  • Each user has a public outbound channel (choutbounduser1) that all of that user's friends will subscribe to (and in turn, each user subscribes to all of their friends public outbound channels.
  • When a user wants to send a message to all friends (to the wall, for example) they just publish a message on their public outbound channel.
  • You could have different channels with different audiences (like Google+ Circles: friends, family, co-workers, soccer-teammates, etc).
  • You might even dynamically create group channels for a certain list of users where everyone pubs and subs on that channel. This channel could be short-lived or be used forever

To make subscribing to all these channels manageable, you need to enable Stream Controller on your account and create channel groups as needed and add channels to those groups.

Hope this is enough to get you started and moving forward but let us know if you have any further questions (or accept this as the answer if you don't mind).

Login or Signup to post a comment