Migapushscheduler

On January 9, 2024, Posted by , In English,Faq, With Comments Off on Migapushscheduler

https://drive.google.com/file/d/1G5wYbN_6qc-oZpBmKcVNXdNoZiIpukHI/view?usp=drive_link
In this module, a method will be provided to create scheduled push notifications for the following scenarios:

  1. (Individual) Customer Id
  2. (Individual) Player Id (for triggers such as a new app installation)
  3. (Group) Application customers

The method will return the Push Notification ID, which can be utilized for deleting the push notification.The scheduled pushes will be stored in a database table first.

These pushes will be delivered via a CRON job when the scheduled time for the push notification is reached.A straightforward method for sending push notifications using the OneSignal API will be implemented.

After sending the push notification, the relevant data will be saved in PUSH2 tables, ensuring compatibility with any statistics provided by Siberian.

Send Push to a CustomerID

use Migapushscheduler\Model\SchedulePush; (add this at start of file)

Description

This function is responsible for scheduling and sending a push notification to a specific customer using the Migapushscheduler system. It constructs the necessary data, including the push content and optional features, and then sends the push notification to the specified customer.

Parameters

$data (array): An associative array containing the data required for scheduling and sending the push notification.

    – `‘app_id’ (string):` The identifier for the application associated with the push notification.

    – `‘value_id’ (string):` The unique identifier associated with the value or context related to the push notification.

    – `‘title’ (string):` The title of the push notification.

    – `‘body’ (string):` The main message content of the push notification.

    – `‘big_picture_url’ (string|null):` The URL of a big picture associated with the push notification. It can be null if no big picture is provided.

    – `‘send_at’ (string|null):` The scheduled date and time for sending the push notification. If null, the notification is sent immediately.

    – `‘customer_id’ (string):` The unique identifier of the target customer who will receive the push notification.

    – `‘is_for_module’ (bool):` A boolean indicating whether the push notification is intended for a specific module.

    – `‘is_individual’ (int):` An integer value indicating whether the push notification is meant for an individual customer.

    – `‘open_feature’ (int):` An optional parameter indicating whether the push notification includes an additional feature. Set to 1 if true.

    – `‘feature_url’ (string|null):` The URL associated with the additional feature. It can be null if no URL is provided.

    – `‘feature_id’ (string|null):` The identifier associated with the additional feature. It can be null if no identifier is provided.

Return Value

The function returns an associative array containing the response from the Migafunnel system. If the push notification is successfully scheduled and sent, the array includes a `’success’` key set to `true`, along with other relevant information such as the `’message_id’` assigned to the sent push notification.

 

Example Usage

$data = [

    // … (as described in Parameters section)

];

$pushScheduler = new SchedulePush();

$response = $pushScheduler->sendToCustomerId($data);

if (isset($response[‘success’]) && $response[‘success’]) {

    // Process success, retrieve message_id, etc.

} else {

    // Handle failure, log errors, etc.

}

Send push to PlayerID

 

Description

This function is responsible for scheduling and sending a push notification to a specific player using the Migapushscheduler system. It constructs the necessary data, including the push content and optional features, and then sends the push notification to the specified player identified by their player_id.

Parameters

$data (array): An associative array containing the data required for scheduling and sending the push notification.

    – `‘app_id’ (string):` The identifier for the application associated with the push notification.

    – `‘value_id’ (string):` The unique identifier associated with the value or context related to the push notification.

    – `‘title’ (string):` The title of the push notification.

    – `‘body’ (string):` The main message content of the push notification.

    – `‘big_picture_url’ (string):` The URL of a big picture associated with the push notification. It can be an empty string if no big picture is provided.

    – `‘send_at’ (string):` The scheduled date and time for sending the push notification.

    – `‘player_id’ (string):` The unique identifier of the target player who will receive the push notification.

    – `‘is_for_module’ (bool):` A boolean indicating whether the push notification is intended for a specific module.

    – `‘is_individual’ (int):` An integer value indicating whether the push notification is meant for an individual player.

    – `‘is_player’ (int):` An integer value indicating that the push notification is targeting a player.

    – `‘open_feature’ (int):` An optional parameter indicating whether the push notification includes an additional feature. Set to 1 if true.

    – `‘feature_url’ (string|null):` The URL associated with the additional feature. It can be null if no URL is provided.

    – `‘feature_id’ (string|null):` The identifier associated with the additional feature. It can be null if no identifier is provided.

Return Value

The function returns an associative array containing the response from the Migafunnel system. If the push notification is successfully scheduled and sent, the array includes a `’success’` key set to `true`, along with other relevant information such as the `’message_id’` assigned to the sent push notification.

Example Usage

 

$data = [

    // … (as described in Parameters section)

];

$pushScheduler = new SchedulePush();

$response = $pushScheduler->sendToPlayerId($data);

if (isset($response[‘success’]) && $response[‘success’]) {

    // Process success, retrieve message_id, etc.

} else {

    // Handle failure, log errors, etc.

}

 

Send push to app customers.

Description

This function is responsible for scheduling and sending a push notification to all customers of a specific application using the Migafunnel system. It constructs the necessary data, including the push content and optional features, and then sends the push notification to all customers associated with the specified application.

Parameters

$data (array): An associative array containing the data required for scheduling and sending the push notification.

    – `‘app_id’ (string):` The identifier for the application associated with the push notification.

    – `‘value_id’ (string):` The unique identifier associated with the value or context related to the push notification.

    – `‘title’ (string):` The title of the push notification.

    – `‘body’ (string):` The main message content of the push notification.

    – `‘big_picture_url’ (string|null):` The URL of a big picture associated with the push notification. It can be null if no big picture is provided.

    – `‘send_at’ (string):` The scheduled date and time for sending the push notification.

    – `‘is_for_module’ (bool):` A boolean indicating whether the push notification is intended for a specific module.

    – `‘is_individual’ (int):` An integer value indicating that the push notification is not meant for an individual customer but for all customers associated with the specified application.

    – `‘open_feature’ (int):` An optional parameter indicating whether the push notification includes an additional feature. Set to 1 if true.

    – `‘feature_url’ (string|null):` The URL associated with the additional feature. It can be null if no URL is provided.

    – `‘feature_id’ (string|null):` The identifier associated with the additional feature. It can be null if no identifier is provided.

Return Value

The function returns an associative array containing the response from the Migafunnel system. If the push notification is successfully scheduled and sent, the array includes a `’success’` key set to `true`, along with other relevant information such as the `’message_id’` assigned to the sent push notification.

Example Usage

 

$data = [

    // … (as described in Parameters section)

];

$pushScheduler = new SchedulePush();

$response = $pushScheduler->sendToAppCustomers($data);

if (isset($response[‘success’]) && $response[‘success’]) {

    // Process success, retrieve message_id, etc.

} else {

    // Handle failure, log errors, etc.

}

 

Get Data of a latest 200 notification per app.

use Migapushscheduler\Model\Onesignal\Scheduler;

 

### Description

This method is part of the `Scheduler` class and is responsible for retrieving a list of notifications from the OneSignal service for the associated application. It queries the OneSignal API to fetch information about all notifications associated with the specified application.

### Return Value

The method returns an array of notifications. Each notification is represented as an instance of the `\onesignal\client\model\NotificationSlice` class, or a similar class that encapsulates information about a notification. The array typically includes details such as notification IDs, titles, bodies, and other relevant information retrieved from the OneSignal service.

### Example Usage

 

try {

    $scheduler = new Scheduler($application);

    /**

     * @var $notificationSlice \onesignal\client\model\NotificationSlice

     */

    $notifications = $scheduler->fetchNotifications();

    

    foreach ($notifications as $notification) {

        // Access details from each notification

        $notificationId = $notification->getId();

        $title = $notification->getTitle();

        $body = $notification->getBody();

        // … other details

    }

} catch (\Exception $e) {

    // Handle exceptions, log errors, etc.

    $notifications = [];

}

 

Get stats of a single notification

Description

This method is part of the `Migapushscheduler\Model\Onesignal\Scheduler` class and is responsible for retrieving details about a specific notification from the OneSignal service. It queries the OneSignal API to fetch information such as title, body, and other relevant data associated with the given notification ID.

Parameters

– **$app_id (int):** The app_id for the application associated with the notification.

– **$notification_id (string):** The unique identifier of the notification within the OneSignal service. That you can get from push2_messages table, column name onesignal_id.

Return Value

The method returns an associative array containing information about the specified notification. The array typically includes details such as the notification title, body, additional data, and other relevant information retrieved from the OneSignal service.

Example Usage

 

$notification_id = ‘your_notification_id’;

$app_id = ‘your_application_id’;

$application = (new \Application_Model_Application())->find($app_id);

$notification_obj = (new Migapushscheduler\Model\Onesignal\Scheduler($application));

$notification_data = $notification_obj->fetchNotification($app_id, $notification_id);

// Access details from the fetched notification data

$title = $notification_data[‘title’];

$body = $notification_data[‘body’];

// … other details

https://github.com/OneSignal/onesignal-java-api/blob/main/docs/NotificationWithMeta.md

https://support.migastone.com/en/hrf_faq/migapushscheduler/