REST Interface

Last updated on
30 April 2025

Mobile apps can register the device by calling the REST interface provided by the Services module. Don't forget to enable the Push Notifications module. This module adds a permission called 'register device token'. Only roles with this permission may register a device token through a service. This module should work with both anonymous and authenticated users.

Arguments

This service requires 2 arguments:

  • 'token' (string): The iOS device token (which is not the same as the iOS UDID) or the Android registration id
  • 'type' (string): Pass 'ios' for ios device tokens and 'android' for android registration ids

Result

If successful, the service returns an array with two keys:

  • 'success', value is 1
  • 'message', value is either 'This token is already registered to this user.' if the token was already registered or 'This token was successfully stored in the database.' for new tokens

Register a token - Step by Step

Navigate to the Services admin interface at admin/structure/services

Services overview

Add a new services endpoint. For this example, I'm going to create an endpoint called "mobile_data". This will be the base URL for your services, e.g. http://www.yoursite.com/mobile_data

Add Services Endpoint

You should see your new endpoint listed at admin/structure/service. Click on "Edit Resources" for that endpoint.

See New Endpoint

On the "Resource" page for that endpoint, you will see a list of all resources. Make sure "push_notifications" and "create" underneath it is enabled.

Services Resources

Make sure to enable all parsing types you want, e.g. if you're sending url-encoded data, make sure it's enabled

Parsing Types

These are all the steps you need to take to enable your services endpoint. You can then register your device token at http://www.yoursite.com/mobile_data/push_notifications. You should use a POST on that URL and pass two arguments

Register token

Unregister token

Help improve this page

Page status: Not set

You can: