Users_Device Class
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.
Item Index
Methods
__set_state
-
$array
Implements the __set_state method, so it can work with with var_export and be re-imported successfully.
Parameters:
-
$array
Array
Returns:
Class instance
byApp
-
[$userId=Users::loggedInUser()]
-
[$platform=Q_Request::platform()]
-
[$appId=Q::app()]
Given a userId and optional platform and appId, retrieve an array of the latest devices, ordered by time inserted.
Parameters:
-
[$userId=Users::loggedInUser()]
String optionalThe id of the user
-
[$platform=Q_Request::platform()]
String optionalThe external platform
-
[$appId=Q::app()]
String optionalExternal or internal platform app id
Returns:
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 optionalEither the text of an alert to show, or an object with the following fields:
-
[title]
String optionalThe title of the notification -
[body]
String optionalThe body of the notification -
[titleLocKey]
String optionalApple-only -
[titleLocArgs]
String optionalApple-only -
[actionLocKey]
String optionalApple-only -
[locKey]
String optionalApple-only -
[locArgs]
String optionalApple-only -
[launchImage]
String optionalApple-only
-
-
[badge]
String optionalThe badge
-
[sound]
String optionalThe name of the sound file in the app bundle or Library/Sounds folder
-
[icon]
String optionalUrl of icon, can be png any square size
-
[url]
String optionalUrl to which the notifiation will be linked
-
[actions]
Array optionalArray of up to two arrays with keys 'action' and 'title'.
-
[category]
String optionalApple-only. The name of the category for actions registered on the client side.
-
[payload]
Array optionalPut all your custom notification fields here
-
[expiry=null]
Integer optionalNumber 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 optionalCan be set to "normal" to make it lower priority
-
[collapseId]
String optionalA string under 64 bytes for collapsing notifications
-
[id]
String optionalYou can provide your own uuid for the notification
-
-
[$options]
Array optional-
[scheduled=false]
Boolean optionalif true, doesn't send immediately. You should call UsersDevice{YourPlatform}::sendPushNotifications() to send all scheduled notifications in a batch.
-
[silent=false]
Boolean optionalDeliver 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.