You are here

function push_notifications_check_payload_size in Push Notifications 7

Check size of a push notification payload. Payload can't exceed PUSH_NOTIFICATIONS_APNS_PAYLOAD_SIZE_LIMIT.

Parameters

$payload: Message.

Return value

Returns true if message is below the limit, false otherwise.

1 call to push_notifications_check_payload_size()
push_notifications_mass_push_form_validate in includes/push_notifications.admin.inc
Validation handler for sending out a mass-push notification.

File

./push_notifications.module, line 457
Push Notifications functionality.

Code

function push_notifications_check_payload_size($payload = '') {
  if ($payload == '') {
    return FALSE;
  }

  // JSON-encode the payload.
  $payload = json_encode($payload);

  // Verify that the payload doesn't exceed limit.
  $payload_size = mb_strlen($payload, '8bit');
  $size_valid = $payload_size > PUSH_NOTIFICATIONS_APNS_PAYLOAD_SIZE_LIMIT ? FALSE : TRUE;
  return $size_valid;
}