Constructor.
Initializes a database connection and perfoms any tasks that have been assigned.
Create a new PHP file named apns.php on your website...
<?php
$db->show_errors();
?>
Your iPhone App Delegate.m file will point to a PHP file with this APNS Object. The url will end up looking something like: https://secure.yourwebsite.com/apns.php?task=register&appname=My%20App&appversion=1.0.1&deviceuid=e018c2e46efe185d6b1107aa942085a59bb865d9&devicetoken=43df9e97b09ef464a6cf7561f9f339cb1b6ba38d8dc946edd79f1596ac1b0f66&devicename=My%20Awesome%20iPhone&devicemodel=iPhone&deviceversion=3.1.2&pushbadge=enabled&pushalert=disabled&pushsound=enabled
APNS
__construct
(object $db, [array $args = NULL])
-
object
$db: Database Object
-
array
$args: Optional arguments passed through $argv or $_GET
Add Message Alert
<?php
$db->show_errors();
// SIMPLE ALERT
$apns->addMessageAlert('Message received from Bob'); // MAKES DEFAULT BUTTON WITH BOTH 'Close' AND 'View' BUTTONS
// CUSTOM 'View' BUTTON
$apns->addMessageAlert('Bob wants to play poker', 'PLAY'); // MAKES THE 'View' BUTTON READ 'PLAY'
// NO 'View' BUTTON
$apns->addMessageAlert('Bob wants to play poker', ''); // MAKES AN ALERT WITH JUST AN 'OK' BUTTON
// CUSTOM LOCALIZATION STRING FOR YOUR APP
$apns->addMessageAlert(NULL, NULL, 'GAME_PLAY_REQUEST_FORMAT', array('Jenna', 'Frank'));
?>
void
addMessageAlert
([ $alert = NULL], [ $actionlockey = NULL], [ $lockey = NULL], [ $locargs = NULL], int $number)
-
int
$number
-
$alert
-
$actionlockey
-
$lockey
-
$locargs
Add Message Badge
<?php
$db->show_errors();
?>
void
addMessageBadge
([int $number = NULL])
Add Message Custom
<?php
$db->show_errors();
?>
void
addMessageCustom
([string $key = NULL], [mixed $value = NULL])
-
string
$key: Name of Custom Object you want to pass back to your iPhone App
-
mixed
$value: Mixed Value you want to pass back. Can be int, bool, string, or array.
Add Message Sound
<?php
$db->show_errors();
?>
void
addMessageSound
([string $sound = NULL])
-
string
$sound: Name of sound file in your Resources Directory
Start a New Message
<?php
$db->show_errors();
$apns =
new APNS($db); // CREATE THE OBJECT
$apns->newMessage(1, '2010-01-01 00:00:00'); // START A MESSAGE... SECOND ARGUMENT ACCEPTS ANY DATETIME STRING
$apns->addMessageAlert('You got your emails.'); // ALERTS ARE TRICKY... SEE EXAMPLES
$apns->newMessage(array(1,3,4,5,8,15,16)); // SEND MESSAGE TO MORE THAN ONE USER
?>
void
newMessage
(mixed $fk_device, [string $delivery = NULL])
-
mixed
$fk_device: Foreign Key, or Array of Foreign Keys to the device you want to send a message to.
-
string
$delivery: Possible future date to send the message.
Process all queued messages
<?php
$db->show_errors();
?>
void
processQueue
()
Queue Message for Delivery
<?php
$db->show_errors();
?>
void
queueMessage
()