Coder Social home page Coder Social logo

Comments (5)

avramanaareddy avatar avramanaareddy commented on September 26, 2024 1

Yes, I am doing exactly like above, what you mentioned

notification.headers.put("ServiceBusNotification-Apns-Expiry", expiryString);
notification.headers.put("apns-push-type", "alert");
notification.headers.put("apns-priority", "10");
I have printed the same in the log before sending the push notification also.
{apns-push-type=alert, ServiceBusNotification-Apns-Expiry=10/23/2019 03:35:56, ServiceBusNotification-Format=apple, apns-priority=10}

It gives tracking id as 0d104017-4d70-44d3-86c6-ee9581157bf0
but I don't get any push notification, i have iOS 13.x apple device.

from azure-notificationhubs-java-backend.

brannon avatar brannon commented on September 26, 2024

@avramanaareddy can you provide a link to the StackOverflow post?

Have you tried setting the apns-priority value to 10 ? As per Apple documentation, a value of 10 is appropriate for "alert" notifications. Notifications sent with a value of 5 are subject to batching, throttling, or being dropped.

https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/sending_notification_requests_to_apns

Your code snippet is referencing a private member of the Notification class:

notification.headers.put(...);

Are you instead using the following?

notification.getHeaders().put(...);

from azure-notificationhubs-java-backend.

avramanaareddy avatar avramanaareddy commented on September 26, 2024

Let me try

from azure-notificationhubs-java-backend.

omerh86 avatar omerh86 commented on September 26, 2024

Is there any update?, I'm having same issue

from azure-notificationhubs-java-backend.

mpodwysocki avatar mpodwysocki commented on September 26, 2024

Cannot reproduce the issue. Complete with verified code:

package com.microsoft.azure;

import com.windowsazure.messaging.*;

import java.util.HashMap;
import java.util.Map;

class Program {
    public static void main(String [] arguments) {
        String connectionString = "xxxx";
        String hubName = "xxxx";
        String apnsBody = "{\"aps\":{\"alert\":\"Notification Hub test notification\"}}";

        Map<String, String> headers = new HashMap<>();
        headers.put("ServiceBusNotification-Format", "apple");
        headers.put("apns-push-type", "alert");
        headers.put("apns-priority", "5");
        headers.put("ServiceBusNotification-DeviceHandle", "xxxx");

        NotificationHubClient client = new NotificationHub(connectionString, hubName);
        Notification n = Notification.createAppleNotification(apnsBody, headers);
        try {
            NotificationOutcome outcome = client.sendNotification(n);
            System.out.println("Tracking ID: " + outcome.getTrackingId());
        } catch (NotificationHubsException e) {
            e.printStackTrace();
        }
    }

This works with both apns-priority set to 5 or 10.

from azure-notificationhubs-java-backend.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.