You are here

function push_notifications_purge_token in Push Notifications 7

Delete a token.

Parameters

$token: Device token.

$type_id: Device Type ID.

5 calls to push_notifications_purge_token()
push_notifications_apns_feedback_service in ./push_notifications.module
Connect to Apple's feedback server to remove unused device tokens. Connection modeled after daddyhunt_apns_send_notifications function.
push_notifications_c2dm_send_message in ./push_notifications.module
Send out push notifications through C2DM.
push_notifications_fcm_send_message in ./push_notifications.module
Send out push notifications through FCM.
push_notifications_gcm_send_message in ./push_notifications.module
Send out push notifications through GCM.
_push_notifications_service_delete_device_token in includes/push_notifications.service.inc
Deletes an already registered token.

File

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

Code

function push_notifications_purge_token($token = '', $type_id = '') {
  if ($token == '' || !is_string($token)) {
    return FALSE;
  }

  // Allows other modules to respond to a token being purged.
  module_invoke_all('push_notifications_purge_token', $token, $type_id);

  // Invoke rules.
  if (module_exists('rules')) {
    rules_invoke_event_by_args('push_notifications_before_token_delete', array(
      'token' => $token,
      'type_id' => $type_id,
    ));
  }
  $query = db_delete('push_notifications_tokens');
  $query
    ->condition('token', $token);
  $result = $query
    ->execute();

  // Invoke rules.
  if (module_exists('rules')) {
    rules_invoke_event_by_args('push_notifications_after_token_delete', array(
      'token' => $token,
      'type_id' => $type_id,
    ));
  }
  return $result;
}