Android Push Notification (Slow)

I have an IIS server and send a notification using GoogleCloudMessaging to my phone. It takes about 10 minutes to receive a message on an Android device. This is a huge period of my project. Do you know how to reduce time?

This is C # server code (using PushSharp)

var push = new PushBroker ();

        //Wire up the events for all the services that the broker registers
        /*NotificationSent s = new NotificationSent()
        push.OnNotificationSent += "NotificationSent";
        push.OnChannelException += "ChannelException";
        push.OnServiceException += "ServiceException";
        push.OnNotificationFailed += "NotificationFailed";
        push.OnDeviceSubscriptionExpired += "DeviceSubscriptionExpired";
        push.OnDeviceSubscriptionChanged += "DeviceSubscriptionChanged";
        push.OnChannelCreated += "ChannelCreated";
        push.OnChannelDestroyed += "ChannelDestroyed";
        */

        push.RegisterGcmService(new GcmPushChannelSettings("MY API KEY"));

        push.QueueNotification(new GcmNotification().
            ForDeviceRegistrationId("PHONE REGISTRATION ID")
                              .WithJson(@"{""alert"":""Name !"",""badge"":7,""sound"":""sound.caf""}"));


        //Stop and wait for the queues to drains
        push.StopAllServices();

And this is my receiver

The public class GcmBroadcastReceiver extends WakefulBroadcastReceiver {

@Override
public void onReceive(Context context, Intent intent) {
     // Explicitly specify that GcmIntentService will handle the intent.
    ComponentName comp = new ComponentName(context.getPackageName(),
            GcmIntentService.class.getName());
    // Start the service, keeping the device awake while it is launching.
    startWakefulService(context, (intent.setComponent(comp)));
    setResultCode(Activity.RESULT_OK);

}

}

+4
source share
1 answer

, wifi , Google , Wi-Fi .

, 3-4 , .

+3

Source: https://habr.com/ru/post/1532888/


All Articles