Show:

Users_Device Class

Extends Base_Users_Device
Module: Users

Class representing 'Device' rows in the 'Users' database You can create an object of this class either to access its non-static methods, or to actually represent a device row in the Users database.

Methods

__set_state

(
  • $array
)
Users_Device

Implements the __set_state method, so it can work with with var_export and be re-imported successfully.

Parameters:

  • $array Array

Returns:

Users_Device:

Class instance

byApp

(
  • [$userId=Users::loggedInUser()]
  • [$platform=Q_Request::platform()]
  • [$appId=Q::app()]
)
Array static

Given a userId and optional platform and appId, retrieve an array of the latest devices, ordered by time inserted.

Parameters:

  • [$userId=Users::loggedInUser()] String optional

    The id of the user

  • [$platform=Q_Request::platform()] String optional

    The external platform

  • [$appId=Q::app()] String optional

    External or internal platform app id

Returns:

Array:

handlePushNotification

()

Schedules a push notification. This default implementation, just throws an error.

pushNotification

(
  • $notification
  • [$options]
)

You can use this method to send push notifications. It is far better, however, to use the Qbix Platform's offline notification mechanisms using Node.js instead of PHP. That way, you can be sure of re-using the same persistent connection.

Parameters:

  • $notification Array
    • [alert] String | Array optional

      Either the text of an alert to show, or an object with the following fields:

      • [title] String optional
        The title of the notification
      • [body] String optional
        The body of the notification
      • [titleLocKey] String optional
        Apple-only
      • [titleLocArgs] String optional
        Apple-only
      • [actionLocKey] String optional
        Apple-only
      • [locKey] String optional
        Apple-only
      • [locArgs] String optional
        Apple-only
      • [launchImage] String optional
        Apple-only
    • [badge] String optional

      The badge

    • [sound] String optional

      The name of the sound file in the app bundle or Library/Sounds folder

    • [icon] String optional

      Url of icon, can be png any square size

    • [url] String optional

      Url to which the notifiation will be linked

    • [actions] Array optional

      Array of up to two arrays with keys 'action' and 'title'.

    • [category] String optional

      Apple-only. The name of the category for actions registered on the client side.

    • [payload] Array optional

      Put all your custom notification fields here

    • [expiry=null] Integer optional

      Number of seconds until notification expires and does not need to be stored anymore on the device. Pass -1 to ask the device not to store it at all.

    • [priority="high"] String optional

      Can be set to "normal" to make it lower priority

    • [collapseId] String optional

      A string under 64 bytes for collapsing notifications

    • [id] String optional

      You can provide your own uuid for the notification

  • [$options] Array optional
    • [scheduled=false] Boolean optional

      if true, doesn't send immediately. You should call UsersDevice{YourPlatform}::sendPushNotifications() to send all scheduled notifications in a batch.

    • [silent=false] Boolean optional

      Deliver a silent notification, may throw an exception

sendPushNotifications Default implementation

()

Sends all scheduled push notifications

setUp

()

The setUp() method is called the first time an object of this class is constructed.