Crear destino push
Use this endpoint to register a device for push notifications.
/account/targets/pushAlcance targets.writeSDK: solo @owbase/web
Use this endpoint to register a device for push notifications. Provide a target ID (custom or generated using ID.unique()), a device identifier (usually a device token), and optionally specify which provider should send notifications to this target. The target is automatically linked to the current session and includes device information like brand and model. A session holds one push target per provider, so if one already exists this endpoint updates and returns that target instead of creating a second one, and a device that rotates its token is never notified twice.
Parámetros
Sección titulada «Parámetros»targetId string obligatorio
Target ID. Choose a custom ID or generate a random ID with ID.unique(). Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can’t start with a special char. Max length is 36 chars.
identifier string obligatorio
The target identifier (token, email, phone etc.)
providerId string
Provider ID. Message will be sent to this target from the specified provider ID. If no provider ID is set the first setup provider will be used.
bundleId string
App bundle ID of the device registering an APNs token. Without providerId, routes the target to the enabled APNs provider for this bundle ID and environment.
environment string
APNs environment the token belongs to, sandbox or production. Used with bundleId.
Acceso: sesión del usuario (vale lo que permitan los permisos del recurso).
Respuestas
Sección titulada «Respuestas»201Éxito400Parámetro inválido o faltante401Sin sesión, sin permiso en el recurso o clave sin el alcance429Límite de peticionesTodo error llega como JSON con code, type y message: consulta Errores.
import { Client, Account } from '@owbase/web';
const client = new Client() .setEndpoint('https://cloud.owbase.dev/v1') // Your API Endpoint .setProject('<YOUR_PROJECT_ID>'); // Your project ID
const account = new Account(client);
const result = await account.createPushTarget({ targetId: '<TARGET_ID>', identifier: '<IDENTIFIER>', providerId: '<PROVIDER_ID>', // optional bundleId: '<BUNDLE_ID>', // optional environment: 'sandbox', // optional});
console.log(result);curl -X POST "https://cloud.owbase.dev/v1/account/targets/push" \ -H "X-Owbase-Project: <PROJECT_ID>" \ -H "X-Owbase-Session: <SESSION>" \ -H "Content-Type: application/json" \ -d '{"targetId":"<TARGET_ID>","identifier":"<IDENTIFIER>"}'{ "$id": "259125845563242502", "$createdAt": "2020-10-15T06:38:00.000+00:00", "$updatedAt": "2020-10-15T06:38:00.000+00:00", "name": "Apple iPhone 12", "userId": "259125845563242502", "providerId": "259125845563242502", "providerType": "email", "identifier": "token", "expired": false}Las descripciones de esta página vienen de la especificación de la API del servidor (licencia BSD-3-Clause), en inglés, y los ejemplos vienen del generador de SDKs (licencia MIT). Los avisos completos están en el archivo NOTICE de los paquetes @owbase/web y @owbase/node.