title: Java Invalid hex character: h
body: <p>I am using Java 8 with Spring and Maven.</p>
  
  <p>I am trying to set up Push Notifications based on the <a href="https://medium.com/@ankushaggarwal/push-notifications-in-ionic-2-658461108c59" rel="nofollow noreferrer">following tutorial</a>. I have them working perfectly for <strong>Android</strong>, using the following:</p>
  
  <p><strong>NotificationServiceImpl.java</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>I am however, having an issue trying to set it up for <strong>iOS</strong>. I get the following error:</p>
  
  <blockquote>
  <pre><code>SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
  SLF4J: Defaulting to no-operation (NOP) logger implementation
  SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
  java.lang.RuntimeException: Invalid hex character: h
    at com.notnoop.apns.internal.Utilities.charval(Utilities.java:132)
    at com.notnoop.apns.internal.Utilities.decodeHex(Utilities.java:119)
    at com.notnoop.apns.EnhancedApnsNotification.&lt;init&gt;(EnhancedApnsNotification.java:77)
    at com.notnoop.apns.internal.AbstractApnsService.push(AbstractApnsService.java:54)
    at com.notnoop.apns.internal.ApnsServiceImpl.push(ApnsServiceImpl.java:36)
    at com.notnoop.apns.internal.AbstractApnsService.push(AbstractApnsService.java:45)
    at com.jobs.spring.service.NotificationServiceImpl.sendIOSPushNotification(NotificationServiceImpl.java:90)
  </code></pre>
  </blockquote>
  
  <p>My code for <strong>iOS</strong> is as follows:</p>
  
  <pre><code>/**
   * import com.notnoop.apns.APNS; import com.notnoop.apns.ApnsService;
   * https://github.com/notnoop/java-apns.
   */
  private static 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(topics, payload); // &lt;&lt;&lt;&lt;&lt; line 90
      return "iOS Push Notification: " + title + " " + message;
  }
  </code></pre>
  
  <p>As you can see, the error occurs as a result of the line of code on line 90.</p>
  
  <pre><code>service.push(topics, payload);
  </code></pre>
  
  <p>I think this is a result of the code being different from the <a href="https://medium.com/@ankushaggarwal/push-notifications-in-ionic-2-658461108c59" rel="nofollow noreferrer">tutorial</a>, which is as follows:</p>
  
  <pre><code>service.push(DEVICE_TOKEN, payload);
  </code></pre>
  
  <p>I need my notification service to rather use a <code>topic</code> and not a <code>device token</code> (the client subscribes to a <code>topic</code>). This worked successfully for <strong>Android</strong> as you can see above.</p>
  
  <p><strong>Question</strong></p>
  
  <p>If anyone can shed some light on how I can resolve this <strong>iOS</strong> issue, I would appreciate the help.</p>
  
  <p>Thank you</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I will add a little more info, because from the comments below (thanks for the help), I am told that the parameter should be a <code>devise token</code> and not a <code>topic</code>. </p>
  
  <p>My problem is my client subscribes to a topic. This is business logic that I cannot change. </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>I see the <a href="https://github.com/notnoop/java-apns/blob/master/src/main/java/com/notnoop/apns/ApnsService.java" rel="nofollow noreferrer"><code>com.notnoop.apns.ApnsService</code></a> receives a <code>Collection&lt;String&gt;</code> of devise tokens.</p>
  
  <pre><code>push(Collection&lt;String&gt; deviceTokens, String payload)
  </code></pre>
  
  <p>I will try put my <code>topic</code> <code>String</code> in a <code>Collection</code>, and see if that works.</p>