Не удалось получить push-уведомление с помощью Pushsharp и Pushplugin

Я использую pushplugin в своем приложении Cordova - интерфейс. Для серверной части я использую webapi с уведомлением Pushsharp.

Я могу отправить сообщение в Pushsharp, но не могу получить уведомление. Пожалуйста, предложите. Я использую Pushplugin для создания токена регистрации.

Pushplugin для интерфейса

document.addEventListener("deviceready", function () {
    pushNotification = window.plugins.pushNotification;
});
function InitNotification() {
    $("#app-status-ul").append('<li>registering ' + device.platform + '</li>');
    if (device.platform == 'android' || device.platform == 'Android' || device.platform == "amazon-fireos") {
        pushNotification.register(
            successHandler,
            errorHandler,
            {
                "senderID": "XXXXXXXXXXXXXXX",
                "ecb": "onNotification"
            });
    }
    else {
        pushNotification.register(
            tokenHandler,
            errorHandler,
            {
                "badge": "true",
                "sound": "true",
                "alert": "true",
                "ecb": "onNotificationAPN"
            });
    }}

function successHandler(result) {
    console.log(result);
    alert('result = ' + result);
}

function errorHandler(error) {
    alert('error = ' + error);
}

function onNotification(e) {
    $("#app-status-ul").append('<li>EVENT -> RECEIVED:' + e.event + '</li>');
    switch (e.event) {
        case 'registered':
            if (e.regid.length > 0) {
                $("#app-status-ul").append('<li>REGISTERED -> REGID:' + e.regid + "</li>");
                // Your GCM push server needs to know the regID before it can push to this device
                // here is where you might want to send it the regID for later use.
                alert("regID = " + e.regid);
                var deviceOS = (deviceOs).toLowerCase();
                regID = e.regid;

                registerToken(clientID, regID, deviceOS, deviceId);

            }
            break;

        case 'message':
            // if this flag is set, this notification happened while we were in the foreground.
            // you might want to play a sound to get the user's attention, throw up a dialog, etc.
            if (e.foreground) {
                $("#app-status-ul").append('<li>--INLINE NOTIFICATION--' + '</li>');

                // on Android soundname is outside the payload.
                // On Amazon FireOS all custom attributes are contained within payload
                var soundfile = e.soundname || e.payload.sound;
                // if the notification contains a soundname, play it.
                var my_media = new Media("/android_asset/www/" + soundfile);
                my_media.play();
            }
            else {  // otherwise we were launched because the user touched a notification in the notification tray.
                if (e.coldstart) {
                    $("#app-status-ul").append('<li>--COLDSTART NOTIFICATION--' + '</li>');
                }
                else {
                    $("#app-status-ul").append('<li>--BACKGROUND NOTIFICATION--' + '</li>');
                }
            }


            $("#app-status-ul").append('<li>MESSAGE -> MSG3: ' + e.payload.message + '</li>');

            //Only works for GCM
            $("#app-status-ul").append('<li>MESSAGE -> MSGCNT: ' + e.payload.msgcnt + '</li>');
            ////Only works on Amazon Fire OS
            //$status.append('<li>MESSAGE -> TIME: ' + e.payload.timeStamp + '</li>');
            break;

        case 'error':
            $("#app-status-ul").append('<li>ERROR -> MSG:' + e.msg + '</li>');
            break;

        default:
            $("#app-status-ul").append('<li>EVENT -> Unknown, an event was received and we do not know what it is</li>');
            break;
    }     
}

Pushsharp 4.0 в webapi

[HttpGet]
//[Route("all/{m}/{direct:int:max(1)}")]
public IHttpActionResult All(string m, int direct = 1)
{
    bool isDirect = direct == 1;
    string responseMessage = String.Empty;
    var messagetitle = "PushSharpNotification";
    var APIKey = "YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY";
    var senderId = "XXXXXXXXXXXXX";
    var message = m;
    try
    {
        if (String.IsNullOrEmpty(m) || m.Length <= 2 || m.Length > 60)
            throw new Exception("The message must be between 3 and 60 characters!");
        var UserTokenID = DatabaseContext.MobileDevice.Select(x => x.PushNotificationsRegistrationID).ToList();

        var config = new GcmConfiguration(senderId,APIKey, null);
        config.GcmUrl = "https://fcm.googleapis.com/fcm/send"; //!!!!!gmc changed to fcm;)

        var gcmBroker = new GcmServiceBroker(config);
        gcmBroker.Start();
        foreach (var regId in UserTokenID)
        {
            // Queue a notification to send
            gcmBroker.QueueNotification(new GcmNotification
            {
                RegistrationIds = new List<string> { regId },
                Notification = JObject.Parse(
                    "{" +
                    "\"title\" : \"" + messagetitle + "\"," +
                    "\"body\" : \"" + message + "\"," +
                    "}"),
            });
        }

        // Stop the broker, wait for it to finish   
        // This isn't done after every message, but after you're
        // done with the broker
        gcmBroker.Stop();

        // Stop the broker, wait for it to finish   
        // This isn't done after every message, but after you're
        // done with the broker
        //  gcmBroker.Stop();
        return Ok(m);
    }
    catch (Exception ex)
    {
        return Ok(ex.Message);
    }
}

person Nitin Raja    schedule 07.02.2017    source источник
comment
Протестируйте свое приложение для Android, отправив уведомления, как указано в принятом ответе: stackoverflow.com/questions/22168819/ , если вы не можете получать уведомления, проблема связана с вашим интерфейсным приложением.   -  person Jose Francis    schedule 08.02.2017
comment
Спасибо Хосе. Это работало для GCM, но не для FCM. Любая идея, почему. Пожалуйста, предложите.   -  person Nitin Raja    schedule 08.02.2017
comment
извини, приятель, я еще не работал на FCM.   -  person Jose Francis    schedule 08.02.2017