/**
* Push a notification to Microsoft's notifications-server
*
* @param string $title The title for the tile to send.
* @param string[optional] $count The count for the tile to send.
* @param string[optional] $image The image for the tile to send.
* @param string[optional] $backTitle The title for the tile backtround to send.
* @param string[optional] $backText The text for the tile background to send.
* @param string[optional] $backImage The image for the tile background to send.
* @param string[optional] $tile The secondary tile to update.
* @param string[optional] $uri The application uri to navigate to.
*/
public static function pushToMicrosoftApp($title, $count = null, $image = null, $backTitle = null, $backText = null, $backImage = null, $tile = null, $uri = null)
{
// get ForkAPI-keys
$publicKey = FrontendModel::getModuleSetting('core', 'fork_api_public_key', '');
$privateKey = FrontendModel::getModuleSetting('core', 'fork_api_private_key', '');
// no keys, so stop here
if ($publicKey == '' || $privateKey == '') {
return;
}
// get all microsoft channel uri's
$channelUris = (array) FrontendModel::getDB()->getColumn('SELECT s.value
FROM users AS i
INNER JOIN users_settings AS s
WHERE i.active = ? AND i.deleted = ? AND s.name = ? AND s.value != ?', array('Y', 'N', 'microsoft_channel_uri', 'N;'));
// no devices, so stop here
if (empty($channelUris)) {
return;
}
// init var
$uris = array();
// loop devices
foreach ($channelUris as $row) {
// unserialize
$row = unserialize($row);
// loop and add
foreach ($row as $item) {
$uris[] = $item;
}
}
// no channel uri's, so stop here
if (empty($uris)) {
return;
}
// require the class
require_once PATH_LIBRARY . '/external/fork_api.php';
// create instance
$forkAPI = new ForkAPI($publicKey, $privateKey);
try {
// push
$forkAPI->microsoftPush($uris, $title, $count, $image, $backTitle, $backText, $backImage, $tile, $uri);
} catch (Exception $e) {
if (SPOON_DEBUG) {
throw $e;
}
}
}