Skip to content

Sending push notifications success BUT not receiving any #840

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
dejpanah opened this issue Jul 23, 2017 · 9 comments
Open

Sending push notifications success BUT not receiving any #840

dejpanah opened this issue Jul 23, 2017 · 9 comments

Comments

@dejpanah
Copy link

What version of PushSharp are you using?

i used version 4.0.10

Describe your issue:

Sending push notifications success BUT not receiving any

static void Main(string[] args)
{

        try
        {
            var config = new ApnsConfiguration(ApnsConfiguration.ApnsServerEnvironment.Production,
             Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SSLCertificates.p12"), "1A@$f234", false);
            
            var apnsBroker = new ApnsServiceBroker(config);
            apnsBroker.ChangeScale(10);
            
            apnsBroker.OnNotificationFailed += (notification, aggregateEx) => {

                aggregateEx.Handle(ex => {

                    if (ex is ApnsNotificationException)
                    {
                        var notificationException = (ApnsNotificationException)ex;
                        var apnsNotification = notificationException.Notification;
                        var statusCode = notificationException.ErrorStatusCode;
                        Console.WriteLine("Apple Notification Failed: ID= " + apnsNotification.Identifier + " Code= " + statusCode);
                        Console.WriteLine(ex.Message);
                        if (ex.InnerException != null)
                            Console.WriteLine(ex.InnerException.Message);
                    }
                    else
                    {
                        Console.WriteLine("Apple Notification Failed for some unknown reason : " + ex.InnerException);
                    }

                    return true;
                });
            };

            apnsBroker.OnNotificationSucceeded += (notification) => {
                Console.WriteLine("" + notification.Expiration);
                Console.WriteLine("IsDeviceRegistrationIdValid => " + notification.IsDeviceRegistrationIdValid());
                Console.WriteLine("Apple Notification Sent!");
            };

            apnsBroker.Start();
            var MY_DEVICE_TOKENS = new string[] { "51B2BE5.......81ED4824ED3..25B2E28DE76F", "D6F3...........42499821F" };

            foreach (var deviceToken in MY_DEVICE_TOKENS)
            {
                apnsBroker.QueueNotification(new ApnsNotification
                {
                    Expiration = DateTime.Now.AddDays(2),
                    DeviceToken = deviceToken,
                    Payload = JObject.Parse("{\"aps\":{\"alert\":{\"title\":\"Test\",\"body\":\"Test push\"},\"url-args\":[]}}")
                });
            }

            apnsBroker.Stop();

        }
        catch (Exception exp)
        {
            if (exp.InnerException != null)
                Console.WriteLine(exp.InnerException.Message);
            Console.WriteLine(exp.Message);
        }

        Console.ReadLine();

    }
@dejpanah
Copy link
Author

i uploading my certification on onesignal site for test and it's work but this code is run and get success sent message but not showing any notification on safari

@isfo
Copy link

isfo commented Jul 31, 2017

any news?

@snoopydo
Copy link

You mention Safari, browser push requires an encrypted & signed payload which your example doesn't do.
Double check that the provisioning profile that your iOS app is using the same certificate as the service that sends the notifications.

@zibrohimov
Copy link

Same issue. I see how many people are facing this problem and it is unbelievable there is still no good response.

The case is, it is hitting the success event, but the device is not receiving any notification on iOS.

Trying http://pushtry.com/ with same certificate, password, and device token receives notification without any problem.

This problem should have a valid explanation, as MANY-MANY people are facing the same.

@snoopydo
Copy link

I would now look at the payload your sending. Apple accepting it doesn't mean its able to be processed by your app, either the library or your app could be quietly eating the notification because it can't parse the payload.
I see from the example that you're using an object for the alert property, try just passing simple text message (which I imagine pushtry will be doing) via this property, also remove the empty url-args property. Also the expiration datetime is set using local time, I would assume this should be UtcNow.

@gegillam
Copy link

I had this problem and in my case, my payload was missing aps: {}

I was sending


{
  "alert": "test",
  "badge": 1,
  "sound": "default",
  "category": "none"
}

instead of

{
  "aps": {
    "alert": "test",
    "badge": 1,
    "sound": "default",
    "category": "none"
  }
}

Thats what fixed it for me

@yogeshkv777
Copy link

same issue here... getting success for both GCM and APNS but notifications are not being sent... no idea where is the problem.

@yogeshkv777
Copy link

any update on this issue? same here... getting success response but notification not delivered to device, creating very uncertainty.

@mbachaalani
Copy link

Hello,

You should use this server side library for push notification in c#:
https://github.com/bytefish/FcmSharp
The steps described to use it, includes a need to reference the serviceAccountKey.json file that is downloaded from the firebase console. This is the file that enables authentication on the channel. Without this enabling the notification sending is not reliable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants