{"id":22602473,"url":"https://github.com/tomloprod/ionic-push-php","last_synced_at":"2025-10-08T23:22:19.016Z","repository":{"id":57071451,"uuid":"76116816","full_name":"tomloprod/ionic-push-php","owner":"tomloprod","description":"ionic-push-php is a library that allows you to consume the Ionic Cloud API for sending push notifications (normal and scheduled), get a paginated list of sending push notifications,  get information of registered devices, remove registered devices by token, ...","archived":false,"fork":false,"pushed_at":"2017-07-17T13:31:32.000Z","size":112,"stargazers_count":21,"open_issues_count":0,"forks_count":8,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-09-24T07:39:32.578Z","etag":null,"topics":["api","curl","ionic","php","push-notifications"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tomloprod.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-12-10T14:16:57.000Z","updated_at":"2023-07-06T20:33:40.000Z","dependencies_parsed_at":"2022-08-24T10:40:55.140Z","dependency_job_id":null,"html_url":"https://github.com/tomloprod/ionic-push-php","commit_stats":null,"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"purl":"pkg:github/tomloprod/ionic-push-php","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomloprod%2Fionic-push-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomloprod%2Fionic-push-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomloprod%2Fionic-push-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomloprod%2Fionic-push-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tomloprod","download_url":"https://codeload.github.com/tomloprod/ionic-push-php/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomloprod%2Fionic-push-php/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279000734,"owners_count":26082862,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-08T02:00:06.501Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","curl","ionic","php","push-notifications"],"created_at":"2024-12-08T12:21:20.364Z","updated_at":"2025-10-08T23:22:19.003Z","avatar_url":"https://github.com/tomloprod.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ionic-push-php [![Release](https://img.shields.io/github/release/tomloprod/ionic-push-php.svg)](https://github.com/tomloprod/ionic-push-php) [![Join the chat at https://gitter.im/tomloprod/ionic-push-php](https://badges.gitter.im/tomloprod/ionic-push-php.svg)](https://gitter.im/tomloprod/ionic-push-php?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge) [![License](https://img.shields.io/github/license/tomloprod/ionic-push-php.svg)](http://www.opensource.org/licenses/mit-license.php)\n\nionic-push-php is a library that allows you to consume the *Ionic Cloud API* for **sending push notifications** (*normal and scheduled*), get a paginated **list of sending push notifications**,  get **information of registered devices**, **remove registered devices by token**, ...\n\nIonic official documentation: [Ionic HTTP API - Push](https://docs.ionic.io/api/endpoints/push.html).\n\n## Requirements:\n\n- PHP 5.1+\n- cURL\n\n## Installation:\n\n    composer require tomloprod/ionic-push-php\n\n## Configuration:\n\nFirst, make sure you have your `$ionicAPIToken` and your `$ionicProfile`:\n\n- (string) **$ionicAPIToken:** The API token that you must create in *Settings › API Keys* in the [Dashboard](https://apps.ionic.io).\n- (string) **$ionicProfile:** The Security Profile tag found in *Settings › Certificates* in the [Dashboard](https://apps.ionic.io)\n\n\u003e More information [here](https://github.com/tomloprod/ionic-push-php/issues/1).\n\nIf you don't know how to configure your ionic app, you can take a look here: [Setup Ionic Push](http://docs.ionic.io/services/push/#setup)\n\n\n## Exceptions\n\nThis library could throw:\n\n- RequestException\n\n````php\necho $e;\necho $e-\u003eprettify();\necho $e-\u003egetCode();\necho $e-\u003egetMessage();\necho $e-\u003egetType();\necho $e-\u003egetLink();\n````\n\n## How to use:\n\nFirst, instance an object as follow:\n\n```php\nuse Tomloprod\\IonicApi\\Push,\n    Tomloprod\\IonicApi\\Exception\\RequestException;\n\n$ionicPushApi = new Push($ionicProfile, $ionicAPIToken);\n```\n\nThen you can interact (*list, remove, create, ...*) with `device tokens`, `messages` and `notifications`.\n\nRemember that all the interactions returns an **ApiResponse** object instance, except __notifications-\u003edeleteAll__ that returns an array of **ApiResponse**s.\n\n\n### [Device Tokens]\n\n **1) List tokens:**\n\n```php\ntry {\n\n  $response = $ionicPushApi-\u003edeviceTokens-\u003epaginatedList([\n      // Determines whether to include invalidated tokens (boolean)\n      'show_invalid' =\u003e 1,\n      // Only display tokens associated with the User ID (string)\n      'user_id' =\u003e $desiredUserId,\n      // Sets the number of items to return per page (integer)\n      'page_size' =\u003e 4,\n      // Sets the page number (integer)\n      'page' =\u003e 1\n  ]);\n\n  foreach($response-\u003edata as $deviceToken){        \n      print_r($deviceToken);\n  }\n\n} catch(RequestException $e) {\n  echo $e;\n}\n```\n\n**2) List users associated with a device token:**\n\n```php\ntry {\n\n  $response = $ionicPushApi-\u003edeviceTokens-\u003elistAssociatedUsers($desiredDeviceToken, [\n      // Sets the number of items to return per page (integer)\n      'page_size' =\u003e 1,\n      // Sets the page number (integer)\n      'page' =\u003e 1,\n  ]);\n\n  // Do what you want with $response-\u003edata\n\n} catch(RequestException $e) {\n  echo $e;\n}\n```\n\n**3) Associate a user with a device token:**\n\n```php\ntry {\n\n  $deviceToken = \"c686...\";\n  $userId = \"a99ee...\";\n  $ionicPushApi-\u003edeviceTokens-\u003eassociateUser($deviceToken, $userId);\n\n  // The user has been associated.\n\n} catch(RequestException $e) {\n  echo $e;\n}\n```\n\n**4) Dissociate a user with a device token:**\n\n```php\ntry {\n\n  $deviceToken = \"c686...\";\n  $userId = \"a99ee...\";\n  $ionicPushApi-\u003edeviceTokens-\u003edissociateUser($deviceToken, $userId);\n\n  // The user has been dissociated.\n\n} catch(RequestException $e) {\n  echo $e;\n}\n```\n\n**5) Create device token that was previously generated by a device platform:**\n\n```php\ntry {\n\n  $response = $ionicPushApi-\u003edeviceTokens-\u003ecreate([\n      // Device token (string)\n      'token' =\u003e $newToken,\n      // User ID. Associate the token with the User (string)\n      'user_id' =\u003e $uuid\n  ]);\n\n  // Do what you want with $response-\u003edata\n\n} catch(RequestException $e) {\n  echo $e;\n}\n```\n\n**6) Retrieve device information related to the device token:**\n\n```php\ntry {\n\n  $response = $ionicPushApi-\u003edeviceTokens-\u003eretrieve($desiredDeviceToken);\n\n  // Do what you want with $response-\u003edata\n\n} catch(RequestException $e) {\n  echo $e;\n}\n```\n\n**5) Update an specific token:**\n\n```php\ntry {\n\n  $isValid = true; // Determines whether the device token is valid (boolean)\n  $ionicPushApi-\u003edeviceTokens-\u003eupdate($desiredDeviceToken, ['valid' =\u003e $isValid]);\n\n  // The device token has been updated.\n\n} catch(RequestException $e) {\n  echo $e;\n}\n```\n\n**6) Delete a device related to the device token:**\n\n```php\ntry {\n\n  $ionicPushApi-\u003edeviceTokens-\u003edelete($desiredDeviceToken);\n\n  // The device token has been deleted.\n\n} catch(RequestException $e) {\n  echo $e;\n}\n```\n\n### [Messages]\n\n**1) Retrieve specific message:**\n\n```php\ntry {\n  $response = $ionicPushApi-\u003emessages-\u003eretrieve($desiredMessageId);\n\n  // Do what you want with $response-\u003edata\n\n} catch(RequestException $e) {\n  echo $e;\n}\n```\n\n**2) Delete a message:**\n\n```php\ntry {\n  $ionicPushApi-\u003emessages-\u003edelete($desiredMessageId);\n\n  // The message has been deleted.\n\n} catch(RequestException $e) {\n  echo $e;\n}\n```\n\n### [Notifications]\n\n**1) List notifications:**\n```php\n\ntry {\n\n  $response = $ionicPushApi-\u003enotifications-\u003epaginatedList([\n      // Sets the number of items to return per page (integer)\n      'page_size' =\u003e 1,\n      // Sets the page number (integer)\n      'page' =\u003e 1,\n      // You can also pass other fields like \"message_total\" or \"overview\" (string[])\n      'fields' =\u003e [\n          // Total number of messages tied to each notification.\n          'message_total',\n          // Get an overview of messages delivered and failed for each notification.\n          'overview'\n      ]\n  ]);\n\n  // Do what you want with $response-\u003edata\n\n} catch(RequestException $e) {\n  echo $e;\n}\n```\n\n**2) Retrieve specific notification:**\n\n```php\ntry {\n\n  $response = $ionicPushApi-\u003enotifications-\u003eretrieve($desiredNotificationId);\n\n  // Do what you want with $response-\u003edata\n\n} catch(RequestException $e) {\n  echo $e;\n}\n```\n\n**3) Delete a notification:**\n\n```php\ntry {\n  $ionicPushApi-\u003enotifications-\u003edelete($desiredNotificationId);\n\n  // Notification has been deleted.\n\n} catch(RequestException $e) {\n  echo $e;\n}\n```\n\n**4) Delete all notifications:**\n\n```php\ntry {\n?\n  $responses = $ionicPushApi-\u003enotifications-\u003edeleteAll();\n\n  // Notifications have been deleted.\n\n} catch(RequestException $e) {\n  echo $e;\n}\n```\n\n**5) List messages of a notification:**\n\n```php\ntry {\n\n  $response = $ionicPushApi-\u003enotifications-\u003elistMessages($desiredNotificationId, [\n      // Sets the number of items to return per page (integer)\n      'page_size' =\u003e 1,\n      // Sets the page number (integer)\n      'page' =\u003e 1\n  ])\n\n  // Do what you want with $response-\u003edata\n\n} catch(RequestException $e) {\n  echo $e;\n}\n ```\n\n**6) Send notifications:**\n\n```php\n/**\n* ANDROID [OPTIONAL] CONFIG PARAMETERS\n*/\n\n// Filename of the Icon to display with the notification (string)\n$icon = \"icon\";\n\n// Filename or URI of an image file to display with the notification (string)\n$image = \"image\";\n\n// Indicates whether each notification message results in a new entry on the notification center on Android.\n// If not set, each request creates a new notification.\n// If set, and a notification with the same tag is already being shown, the new notification replaces the existing one in notification center.\n$tag = \"yourTagIfYouNeedIt\";\n\n// When this parameter is set to true, it indicates that the message should not be sent until the device becomes active. (boolean)\n$delayWhileIdle = false;\n\n// Identifies a group of messages that can be collapsed, so that only the last message gets sent when delivery can be resumed. (string)\n$collapseKey = \"group1\";\n\n\n/**\n* IOS [OPTIONAL] CONFIG PARAMETERS\n*/\n\n// Message Priority. A value of 10 will cause APNS to attempt immediate delivery.\n// A value of 5 will attempt a delivery which is convenient for battery life. (integer)\n$priority = 10;\n\n// The number to display as the badge of the app icon (integer)\n$badge = 1;\n\n// Alert Title, only applicable for iWatch devices\n$iWatchTitle = \"Hi!\";\n\n\n// Assign the previously defined configuration parameters to each platform, as well as the title and message:\n$notificationConfig = [\n    'title' =\u003e 'Your notification title',\n    'message' =\u003e 'Your notification message. Bla, bla, bla, bla.',\n    'android' =\u003e [\n        'tag' =\u003e $tag,\n        'icon' =\u003e $icon,\n        'image' =\u003e $image,\n        'delay_while_idle' =\u003e $delayWhileIdle,\n        'collapse_key' =\u003e $collapseKey\n    ],\n    'ios' =\u003e [\n        'priority' =\u003e $priority,\n        'badge' =\u003e $badge,\n        'title' =\u003e $iWatchTitle\n    ]\n];\n\n// [OPTIONAL] You can also pass custom data to the notification. Default =\u003e []\n$notificationPayload = [\n    'myCustomField' =\u003e 'This is the content of my customField',\n    'anotherCustomField' =\u003e 'More custom content'\n];\n\n// [OPTIONAL] And define, if you need it, a silent notification. Default =\u003e false\n$silent = true;\n\n// [OPTIONAL] Or/and even a scheduled notification for an indicated datetime. Default =\u003e ''\n$scheduled = '2016-12-10 10:30:10';\n\n// [OPTIONAL] Filename of audio file to play when a notification is received. Setting this to default will use the default device notification sound. Default =\u003e 'default'\n$sound = 'default';\n\n// Configure notification:\n$ionicPushApi-\u003enotifications-\u003esetConfig($notificationConfig, $notificationPayload, $silent, $scheduled, $sound);\n\ntry {\n\n  // Send notification...\n  $response = $ionicPushApi-\u003enotifications-\u003esendNotificationToAll(); // ...to all registered devices\n  // or\n  $response = $ionicPushApi-\u003enotifications-\u003esendNotification([$desiredToken1, $desiredToken2, $desiredToken3]); // ...to some devices\n\n  // Do what you want with $response-\u003edata\n\n} catch(RequestException $e) {\n  echo $e;\n}\n```\n\n**7) Replace existing notification with new config:**\n\n```php\n\n// Identifier of the notification we want to replace.\n$notificationToReplace = \"a86feewx...\";\n\n/**\n* ANDROID [OPTIONAL] CONFIG PARAMETERS\n*/\n\n// Filename of the Icon to display with the new notification (string)\n$icon = \"icon\";\n\n// Filename or URI of an image file to display with the new notification (string)\n$image = \"image\";\n\n// Indicates whether each notification message results in a new entry on the notification center on Android.\n// If not set, each request creates a new notification.\n// If set, and a notification with the same tag is already being shown, the new notification replaces the existing one in notification center.\n$tag = \"yourTagIfYouNeedIt\";\n\n// When this parameter is set to true, it indicates that the message should not be sent until the device becomes active. (boolean)\n$delayWhileIdle = false;\n\n// Identifies a group of messages that can be collapsed, so that only the last message gets sent when delivery can be resumed. (string)\n$collapseKey = \"group1\";\n\n\n/**\n* IOS [OPTIONAL] CONFIG PARAMETERS\n*/\n\n// Message Priority. A value of 10 will cause APNS to attempt immediate delivery.\n// A value of 5 will attempt a delivery which is convenient for battery life. (integer)\n$priority = 10;\n\n// The number to display as the badge of the app icon (integer)\n$badge = 1;\n\n// Alert Title, only applicable for iWatch devices\n$iWatchTitle = \"Hi!\";\n\n\n// Assign the previously defined configuration parameters to each platform, as well as the title and message:\n$notificationConfig = [\n    'title' =\u003e 'Your notification title',\n    'message' =\u003e 'Your notification message. Bla, bla, bla, bla.',\n    'android' =\u003e [\n        'tag' =\u003e $tag,\n        'icon' =\u003e $icon,\n        'image' =\u003e $image,\n        'delay_while_idle' =\u003e $delayWhileIdle,\n        'collapse_key' =\u003e $collapseKey\n    ],\n    'ios' =\u003e [\n        'priority' =\u003e $priority,\n        'badge' =\u003e $badge,\n        'title' =\u003e $iWatchTitle\n    ]\n];\n\n// [OPTIONAL] You can also pass custom data to the new notification. Default =\u003e []\n$notificationPayload = [\n    'myCustomField' =\u003e 'This is the content of my customField',\n    'anotherCustomField' =\u003e 'More custom content'\n];\n\n// [OPTIONAL] And define, if you need it, a silent notification. Default =\u003e false\n$silent = true;\n\n// [OPTIONAL] Or/and even a scheduled notification for an indicated datetime. Default =\u003e ''\n$scheduled = '2016-12-10 10:30:10';\n\n// [OPTIONAL] Filename of audio file to play when a notification is received. Setting this to default will use the default device notification sound. Default =\u003e 'default'\n$sound = 'default';\n\n// Configure new notification:\n$ionicPushApi-\u003enotifications-\u003esetConfig($notificationConfig, $notificationPayload, $silent, $scheduled, $sound);\n\ntry {\n\n  // Replace notification with new configuration\n  $response = $ionicPushApi-\u003enotifications-\u003ereplace($notificationToReplace);\n\n  // Do what you want with $response-\u003edata\n\n} catch(RequestException $e) {\n  echo $e;\n}\n```\n\n## Contributing:\n1. Fork it\n1. Create your feature branch (git checkout -b my-new-feature)\n1. Commit your changes (git commit -m 'Add some feature')\n1. Push to the branch (git push origin my-new-feature)\n1. Create new Pull Request","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomloprod%2Fionic-push-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftomloprod%2Fionic-push-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomloprod%2Fionic-push-php/lists"}