Current Location: Home> Latest Articles> Integrating GeTui Push Extension in PHP to Achieve Custom Push Styles and Sound

Integrating GeTui Push Extension in PHP to Achieve Custom Push Styles and Sound

M66 2025-06-07

Introduction

Push notifications are a critical feature in modern applications, helping developers increase user engagement and retention. GeTui is a leading push notification platform in China, offering rich APIs and extensions. This article explains how to integrate the GeTui push extension into a PHP application to customize push notification styles and sounds, meeting diverse push requirements.

1. Overview of GeTui Push Extension

The GeTui push extension is the official SDK supporting multi-platform push integration and customization. By using its interfaces, developers can achieve precise push delivery, custom styles, and personalized sound settings.

2. Customizing Push Styles

Beyond basic titles and content, custom styles make notifications more noticeable. The GeTui extension provides extensive style parameters allowing developers to set push icons, click-through URLs, and display effects.

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.

3. Customizing Push Sound

Push sound enhances message recognition and personalization. The GeTui extension also supports custom sound configuration.

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.

Conclusion

With the GeTui push extension, PHP applications can easily implement customized push styles and sounds to meet diverse business needs. By properly configuring push parameters, you can increase notification attractiveness and boost user interaction. Hope this article helps in your development efforts.