3

I'm using Azure Notification Hubs to push notifications to a Phonegap App currently installed on IOS. I'll also be sending to Android devices but my question is only about IOS at the moment.

My problem is that messages are not delivering sometimes. If I were to send the same notification several times in a row then it might only deliver 50% of the time.

This is my code snippet for sending the notification:

private async Task SendNotificationTemplate(string message, string title = null, int? badgeCount = null, string pageId = null, int? itemId = null, IList<string> tags = null)
    {
        var hub = creatHubClient();
        var notification = new Dictionary<string, string>();

        if (string.IsNullOrEmpty(message))
            throw new InvalidDataException("The message field is required for a notification");

        notification.Add("message", message);

        if (!string.IsNullOrEmpty(title))
            notification.Add("alert_title", title);

        if (!badgeCount.HasValue)
            badgeCount = 1;

        notification.Add("badge_number", badgeCount.ToString());

        notification.Add("page_id", !string.IsNullOrEmpty(pageId) ? pageId : string.Empty);

        notification.Add("id", itemId.HasValue ? itemId.ToString() : "0");

        if (tags == null || tags.Count == 0)
        {
            var result = await hub.SendTemplateNotificationAsync(notification);
            if (result.Success!=0)
            {
                _logger.Error("An error occurred when attempting to send a push notification:" + string.Join(",",result.Results.Select(r=>r.Outcome)));
            }
        }
        else
        {
            var result = await hub.SendTemplateNotificationAsync(notification,tags);
            if (result.Success != 0)
            {
                _logger.Error("An error occurred when attempting to send a push notification:" + string.Join(",", result.Results.Select(r => r.Outcome)));
            }
        }

    }

In the dashboard monitor there are some APNS errors but how can I find out what these are?

I'd appreciate any help or suggestions because the inconsistency here is driving me a bit mad. I know Push notifications aren't guaranteed to be delivered but the delivery rate provided by Apple must be better than what I'm getting. I know my client won't accept it the way it is now!

Here's a screenshot of the Azure Notification Hub Monitor dashboard:

Azure Monitor Thanks John

John Mc
  • 2,862
  • 1
  • 22
  • 37

1 Answers1

0

Check for known issues, in most cases it is something from flowing:

  1. https://stackoverflow.com/a/27806476/2379216
  2. https://stackoverflow.com/a/27492124/2379216
  3. https://stackoverflow.com/a/6496604/2379216
Community
  • 1
  • 1
efimovandr
  • 1,594
  • 9
  • 11
  • Thanks but none of them are applicable, or if they are I have tried what was suggested and it's still the same – John Mc Feb 19 '15 at 09:18
  • Then could you provide an information about APNS errors you see on the dashboard? – efimovandr Feb 19 '15 at 19:56
  • 1
    Azure doesn't give any information - it just says gives the number of APNS errors which is absolutely useless to me. If I knew the error I'd be able to fix this! – John Mc Feb 19 '15 at 21:40
  • 2
    Go to Monitor tab, click +Add Metrics on the bottom of the page, choose APNS tab, check all checkboxes. – efimovandr Feb 19 '15 at 21:46
  • I've updated my question with a screenshot of the monitor tab – John Mc Feb 19 '15 at 22:22
  • 1
    I see... Looks bit strange. I would like to take a look at our logs, to get it I need namespace name, hub name and time when send operations were executed. If you don't have time then try to reproduce the issue again to get it. If for some reasons you don't want to share information here you can email it to me at anefimov@microsoft.com – efimovandr Feb 19 '15 at 23:04