Sample code:
// Set push style
$style = new Style();
$style->setTitle("Custom Title");
$style->setText("Custom Content");
$style->setLogo("http://yourimageurl.com/logo.png");
$style->setLogoURL("http://yourimageurl.com");
$style->setRing(false);
// Create push message
$message = new IGtSingleMessage();
$message->setIsOffline(true); // Enable offline push
$message->setOfflineExpireTime(3600*12); // Offline push expiration time
$message->setData($style);
// Target specific user
$target = new IGtTarget();
$target->setAppId($appId);
$target->setAlias($alias);
$pusher = new IGtPush();
$result = $pusher->pushMessageToSingle($message, $target);
This example shows how to customize title, content, icon, and click URL for personalized push styles. The setLogo method sets the icon, and setLogoURL defines the link after clicking the push.
Sample code:
// Set push sound
$sound = new Sound();
$sound->setBadge(1); // Set unread message count
$sound->setSound("sound.caf");
// Create push message
$message = new IGtSingleMessage();
$message->setIsOffline(true); // Enable offline push
$message->setOfflineExpireTime(3600*12); // Offline push expiration time
$message->setData($sound);
// Target specific user
$target = new IGtTarget();
$target->setAppId($appId);
$target->setAlias($alias);
$pusher = new IGtPush();
$result = $pusher->pushMessageToSingle($message, $target);
This code enables flexible setting of unread message badges and push sounds, supporting common audio formats such as caf and mp3, enhancing the user experience of push notifications.