title: iOS Push Notifications to a topic
body: <p>I have an Ionic app (client), with a Java 8 backend (server), and I have set up push notifications.</p>
  
  <p><strong>client</strong></p>
  
  <pre><code>        let topics: string[] = [this.personModelLoggedIn.uid];
          const options: PushOptions = {
            android: {
              senderID: "XXXXXXXXXXXX",
              sound: "true",
              vibrate: "true",
              topics: topics
            },
            ios: {
              senderID: "XXXXXXXXXXXX",
              alert: "true",
              badge: true,
              sound: "true",
              topics: topics
            },
            windows: {}
          };
  </code></pre>
  
  <p>For <code>Android</code>, I can receive notifications, send from the following:</p>
  
  <p><strong>server</strong></p>
  
  <pre><code>private String sendAndroidPushNotification(String device_token, String topics, String title, String message)
          throws Exception {
      String pushMessage = null;
      if (device_token != null &amp;&amp; !device_token.equals("null")) {
          pushMessage = "{\"data\":{\"title\":\"" + title + "\",\"message\":\"" + message + "\"},\"to\":\""
                  + device_token + "\"}";
      } else {
          pushMessage = "{\"data\":{\"title\":\"" + title + "\",\"message\":\"" + message + "\"},\"to\": \"/topics/"
                  + topics + "\"}";
      }
      // Create connection to send FCM Message request.
      URL url = new URL("https://fcm.googleapis.com/fcm/send");
      HttpURLConnection conn = (HttpURLConnection) url.openConnection();
      conn.setRequestProperty("Authorization", "key=" + SERVER_KEY);
      conn.setRequestProperty("Content-Type", "application/json");
      conn.setRequestMethod("POST");
      conn.setDoOutput(true);
      // Send FCM message content.
      OutputStream outputStream = conn.getOutputStream();
      outputStream.write(pushMessage.getBytes());
  
      return "Android Push Notification: " + conn.getResponseCode() + " " + conn.getResponseMessage() + " - " + pushMessage;
  }
  </code></pre>
  
  <p><strong>Problem</strong></p>
  
  <p>I have the following code for <code>iOS</code>, but the client does not receive the push notifications.</p>
  
  <pre><code>/**
   * import com.notnoop.apns.APNS; import com.notnoop.apns.ApnsService;
   * https://github.com/notnoop/java-apns.
   */
  private String sendIOSPushNotification(String device_token, String topics, String title, String message)
          throws Exception {
      ApnsService service = APNS.newService().withCert(PATH_TO_P12_CERT, CERT_PASSWORD).withSandboxDestination()
              .build();
  
      String payload = APNS.newPayload()
              // .customFields(map)
              .alertBody(title + " " + message).sound("default").build();
  
      service.push(Utilities.encodeHex(topics.getBytes()), payload);
      return "iOS Push Notification: " + title + " " + message;
  }
  </code></pre>
  
  <p>If you look at the <code>com.notnoop.apns</code> api, it is supposed to push to a <code>device token</code>, however, I need it to rather push to a <code>uid</code>. I have implemented the above code to push to a <code>uid</code>, but it doesn't work.</p>
  
  <p><strong>Question</strong></p>
  
  <p>Id it possible for the <code>com.notnoop.apns</code> api to push notifications to a topic? Otherwise, is there another api that will be able to do this?</p>
  
  <p>If neither is possible, should the client rather listen on the <code>device token</code>? But the problem here is, that the sender of the push notification does not know the receivers <code>device token</code>. The sender does know the receivers <code>uid</code> though.</p>
  
  <p>Thanks</p>