Manejo de las notificaciones por SMS en Cordova

improve this page | report issue

Visión general

Las notificaciones SMS son un subconjunto de las notificaciones push, y por lo tanto, primero consulte las guías de aprendizaje de notificaciones push en Cordova.
Se da soporte a las notificaciones SMS en aplicaciones Cordova para iOS y Android.

**Requisitos previos: **

Ir a:

API de notificaciones

En notificaciones SMS, al registrar el dispositivo, se pasa un valor de número de teléfono.

Registrar dispositivo

Registre el dispositivo para el servicio de notificaciones push.

MFPPush.registerNotificationsCallback(notificationReceived);

function registerDevice() {
    var phoneNumber = prompt("Enter Your 10 digit phone number");
    if(phoneNumber != null && phoneNumber!="" && /^\d+$/.test(phoneNumber)) {
        var options = {};
        options.phoneNumber = phoneNumber;
        MFPPush.registerDevice(options, 
        function(successResponse) {
            alert("Successfully registered");
            enableButtons();
        }, function(failureResponse) {
            alert("Failed to register");
        });
        return true;
    }

    else {
        alert("Failed to register, You have entered invalid number");
    }
}

El dispositivo también se puede registrar utilizando la API REST (POST) de registro de dispositivo de push

Utilización de un servlet de suscripción de SMS

Las API REST sirven para enviar notificaciones a dispositivos registrados. Es posible enviar cualquier forma de notificación: notificaciones de difusión y etiqueta y notificaciones autenticadas

Para enviar una notificación, realice una solicitud mediante POST al punto final REST: imfpush/v1/apps/<application-identifier>/messages.

URL de ejemplo:

https://myserver.com:443/imfpush/v1/apps/com.sample.sms/messages

Para revisar todas las API REST de notificaciones push, consulte el tema de los servicios de ejecución de API REST en la documentación de usuario.

Para enviar una notificación, consulte la guía de aprendizaje de envío de notificaciones.

Imagen de la aplicación de ejemplo

Aplicación de ejemplo

Pulse para descargar el proyecto Cordova.

Nota: Se necesita instalada la última versión de Google Play Services en el dispositivo Android para poder ejecutar el ejemplo.

Uso de ejemplo

Siga el archivo README.md de ejemplo para obtener instrucciones.

Inclusive terminology note: The Mobile First Platform team is making changes to support the IBM® initiative to replace racially biased and other discriminatory language in our code and content with more inclusive language. While IBM values the use of inclusive language, terms that are outside of IBM's direct influence are sometimes required for the sake of maintaining user understanding. As other industry leaders join IBM in embracing the use of inclusive language, IBM will continue to update the documentation to reflect those changes.
Last modified on February 27, 2020