How to send notifications (Facebook APP)

First I have a question: does your business leverage the power of Facebook apps? I’ve been using and building apps for Facebook since 2010, first it started as a joke, something to demonstrate myself that I can do it. Now after all these years I still enjoy adding new features to apps, discover new improvements added by Facebook developers and burn my brain trying to figure out how to implement some functionalities.

In this short tutorial I will try to explain how to use Facebook SDK with PHP as programming language for sending notifications on daily basis to users that tried your app at least one time. Why do you need to send notifications? Is simple, you have to remind them about your app in order to increase your APP or page engagement.

Below you will see an example about how to send notification to a Facebook user, I assume you save all unique users IDs that tried at least one time your APP. First you need to include and initiate Facebook SDK, after that all you have to do is make an API call. Is that simple 🙂

<?php
include 'fbsdk/facebook.php';

define('FB_APP_ID', 'YOUR-APP-UNIQUE-ID');
define('FB_APP_SECRET', 'YOUR-APP-SECRET');

// initiate Facebook 
$facebook = new Facebook(array('appId' => FB_APP_ID, 'secret' => FB_APP_SECRET, 'cookie' => true, 'domain' => 'YOUR-DOMAIN'));

// send notification
$fb_response = $facebook->api('/FACEBOOK-USER-UNIQUE-ID/notifications', 'POST', array('access_token' => FB_APP_ID . '|' . FB_APP_SECRET, 'href' => '', 'template' => 'YOUR-NOTIFICATION-SHORT-MESSAGE'));
if ($fb_response['success'] == false) { // in case of an error do something here }    
unset($facebook);

There are so many things that can be done with this feature, for further info check this official Facebook help page.