Thursday, 3 November 2011

[How To] fix push notifications in Facebook for Android

But it doesn't have to!
Hello friends, did you know that Facebook for Android includes push notifications for wall posts, comments, and event invites? Did you know they don’t work properly?
I’m willing to bet that most of you, dear readers, are familiar with the reasonably bare bones official Facebook application provided for Android devices and its fundamentally broken notification system, so today I’m going to tell you how to make it a whole lot better.

The solution is rather unorthodox, but it gets the job done. Turn to page 2 to find out what happens after the jump, because we’re going to get a little help from a Blackberry.

Here's a few musings on push notifications in Android and my experiences with the official Facebook app leading up to this article. If you're just after the guide, scroll down to the second header.

On Push Notifications:

Push notifications are great. If you’re not in the know, push is when a server sends a tiny alert out to a remote device to tell it to download new information - such as email, news, Twitter, and yes, Facebook updates - as soon as the new information is available, rather than the device having to ask for that information  at a regular interval (This is known as ‘pulling’, or ‘polling’ for content, like POP3 and IMAP email). Those that are familiar with iOS and Windows Phone certainly know all about push notifications. Google’s app suite aside, Android tends to go for somewhat less helpful options - like having apps’ own services running constantly in the background, chewing up battery life and 'wake-locking' like crazy. Last year at Google IO, Google brought out its own push notification API system for Android 2.2+, known as C2DM, and apps that use it are always welcome (C2DM stands for Cloud to Device Messaging - for a more in-depth look at C2DM and what it does, look here - I sat through the entire hour-long video just for you, folks).

Facebook for Android does use C2DM for push notifications, but you wouldn’t know it. It was implemented in Facebook v. 1.5 in December 2010, yet in my experience, it has simply never worked. Maybe after an initial sign-in, it’ll pop up with something exciting like “People you barely remember from a job you had four years ago have invited you to some scamtacular event under the pretense of free McFood vouchers!” (Or is that just my Facebook friends?), but it’ll never work in any practical manner. Arbitrary, inconsistent, and occasional notifications are hardly ‘push’ in any useful sense of the term, so I simply disabled all notifications along with changing the refresh interval to ‘never’ in the Facebook app’s options.
Get used to this new notification icon.

Instead, I used to rely on notification emails that go to my Gmail address. I have a specific label in Gmail for everything from Facebook, which is synchronised on my Android devices with its own folder and notification sound. Gmail is pushed pretty reliably, as you'll well know, so this works acceptably enough. The downside being that the emails are sent out by Facebook proper, not the Facebook application, so the links they contain redirect to Facebook Mobile via the browser rather than each alert opening the Facebook app itself. This makes me wonder why I have the Facebook app installed at all – and I’d imagine a lot of people don’t for this very reason – until I remember it has better contact sync than Samsung’s integrated Social Hub system on my Galaxy S II.

So, why did I bother finding out what was up with the Facebook app? Well, I recently switched to the stock Twitter app from Tweetdeck, since Tweetdeck stopped displaying tweets properly. Or, more specifically, I switched from a black version of Tweetdeck (Appropriately called Tweetdark) to a black-themed version of the official Twitter app, ‘cause I’ve gotta save me some battery life with my Galaxy S II’s AMOLED screen. Now, Tweetdeck polls for updates at set intervals rather than using push notifications, so I’d just set it to manual. The official Twitter app, however, has great push notifications that can be enabled for DMs and mentions only, and it will only update your regular timeline every four hours. This inspired me to see if I could get push notifications working in other apps I use, and the Facebook app immediately sprang to mind.

Turns out that, yes, you can get Facebook’s push notifications working, although it’s certainly one of the strangest workarounds I’ve come across. Complex workarounds, sure, I'm familiar with those (Although this isn't 'really' one of them). Geeky workarounds involving a bunch of terminal commands, definitely know them well (Again, no terminals here). Enlisting the help of a Blackberry, now, that’s a new one - and that's the trick. The solution came from ccw1134 over at AndroidCentral who figured it out in May of this year. Y’see, his daughter had working notifications for Facebook, while he did not. In his desperation to find a solution, he checked through the enabled apps on each of their accounts in Facebook proper, and discovered that the only authorised application she had that he didn’t was Facebook for Blackberry, having come to Android from a Blackberry device. He tried signing into Facebook on a Blackberry and authorising said Blackberry app, and bam, push notifications work on Android. Why? Well, your guess is as good as mine – what’s important is that it worked for him, it works for me, and it can work for you too.

Notification preview in the drop-down.
Now, there’s two ways to go about this. The first is to get access to a physical Blackberry running BBOS 5.0 and up, sign into the Facebook app, and away you go. This works fine, assuming you can actually get access to one. Who has a Blackberry these days, anyway? They use them at my work, but I have my doubts that they’re running BBOS 5.0 – and even greater doubts that they’d let me sign into Facebook on one of them on a whim. My uncle’s the only person I know with a recent BB device, the Torch, and he’s unfortunately in another part of the country. Sure, you could try a display model at a Vodafone store, or one of the Telecom business stores, yet that too could be problematic (Not that I’d suggest you’d be silly enough to leave your Facebook details signed in on a display model, dear readers). Also, I’m lazy and impatient, and could not be bothered going and getting a physical device. So, what’s a lazy, impatient geek to do? Why, download the official Blackberry developer emulator, of course. It functions just like a real device, after all.

And thus, do we proceed to the guide.

How to get Push Notifications working in Facebook for Android:

This is the key. Note the icon next to 'Notifications'. Familiar? Soon, it will be.

(Guide assumes Windows, as the only other platform I have to test on is Ubuntu Linux, and I don’t believe RIM offers a Linux-compatible BB emulator)

First up, you’ll have to head to the Blackberry developers’site (There are Blackberry developers? Yeah, news to me too). You’ll need to download two packages:

-          Blackberry Device Simulator 7.0 (177MB)

-          Blackberry Email and MDS Services Simulator Package (44.2MB)

The former contains the device emulator which includes the Facebook app, and the latter allows said emulator to connect to the internets. As a testament to how archaic parts of Research In Motion's site are, you’ll have to download an ‘Akamai NetSession Inferface Console’ plugin to get hold of the Email and MDS package, but that can be readily uninstalled when you’re done with it. For your convenience, I have mirrored the files on mediafire here and here, respectively, but these may not be available for especially long, nor download especially fast.

After you’ve installed the two packages, launch the emulator. It’ll be under Start/All Programs/Research In Motion/Blackberry Simulators 7.0.0/ (9350)/9350. Launching this brings up a seemingly-useless blank command prompt window, followed by the emulator itself, which may need scaling depending on your PC’s screen size. It’ll take a wee while to load up, then boot you into the standard non-touchscreen Blackberry interface. Now you’re in business.

- 1.         Firstly, grab your Android phone. Make sure you have the latest version of Facebook installed from the market.

- 2.        Head to Settings/Applications/Manage Applications. Tap on Facebook, then clear cache and data. Set your Android phone aside.

- 3.         Now jump back on the PC and get into the Blackberry emulator as outlined above. Use your mouse to click on the little Blackberry flag button twice, which will bring up the ‘app drawer’. Use the mouse to move the square D-pad to the Facebook icon, and click the D-pad to launch.

- 4.         Sign in to Facebook on the Blackberry emulator with your regular details. Thankfully, the PC keyboard works, you don’t have to painstakingly click each key on the on-screen Blackberry keyboard!

- 5.         Wait for your feed to load in the Blackberry Facebook app. Once it’s updated with your information, simply log out again.

- 6.         Head to desktop Facebook on your PC. Make sure you’re logged in, then hit the little drop-arrow next to the Home button, and click on Account Settings. While you’re here, take note of the icon next to Notifications down the left-hand side – you’ll be seeing a lot more of this icon very soon.

- 7.         Click on ‘Apps’ down the left-hand side, and make sure ‘Facebook for Blackberry Smartphones’ is authorised. If it’s not, try logging back in on the Blackberry emulator again.

- 8.         Pick your Android phone up once more, and launch the Facebook app. Sign in (Since you cleared data & cache earlier). Once you see your news feed, hit the News Feed logo up top to take you to the app’s main menu. Then press the Menu button, go to Settings, and make sure there is a tick next to Notifications, and the Messages/Friend Requests/Event Invites/Vibrate/LED/Notification Ringtone options are enabled or disabled to your tastes. Personally, I like to put that Facebook Pop notification sound to good use – note that it’s set to silent by default.

- 9.         You can also set the refresh interval to Never, since these are push notifications, and your feed doesn’t have to auto-refresh.

- 10.         Bang, you’re done. Get used to seeing that new notification icon, because wall posts, comments, and replies are going to be pushed your way within a few minutes of being added.

There you have it, folks, push notifications on your phone – or your tablet, since it works on my Asus Transformer as well, as long as you clear the Facebook app’s data/cache – which is also the fix should the notifications stop working again, I’m told. As mentioned above, I find it an odd fix, and I really don’t know why the Blackberry app enables the Android app, but it certainly works for me. Once done, feel free to uninstall the emulator & associated programs, or alternatively keep it around to laugh at how the other half live. Let me know how you get on, good people, and spread the word – it’s made a big difference to the way I use my phone.