Exception on thread "main" java.lang.RuntimeException: Invalid hexadecimal character: v - APNS notnoop

I am trying to implement the notnoop APNS project to send push notifications to iOS devices, but I am getting this output through the console:

Exception on thread "main" java.lang.RuntimeException: Invalid hexadecimal character: v at com.notnoop.apns.internal.Utilities.charVal (Utilities.java:133) at com.notnoop.apns.internal.Utilities.decodeHex (Utilities .java: 120) at com.notnoop.apns.EnhancedApnsNotification. (EnhancedApnsNotification.java:72) 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 PushServiceTryout.main (PushServiceTryout.java:16)

Any ideas on what I am doing wrong? I feel like I'm almost there! Thanks in advance.

EDIT: here is the code. Anyway, I get an error after running the program: s

import com.notnoop.apns.APNS;
import com.notnoop.apns.ApnsService;

public class PushServiceTryout
{
    public static void main(String[] args)
    {
        ApnsService service = APNS.newService()
                .withCert("c:/fcertificates.p12", "1234")
                .withSandboxDestination()
                .build();
        String msg = "Hello";

        String payload = APNS.newPayload().alertBody(msg).build();
        String token = "deviceToken";
        service.push(token, payload);
    }
}

      

+3


source to share


1 answer


This is mistake:

String token = "deviceToken";

      



You cannot use String "deviceToken" as a device token. The device marker consists of 64 hexadecimal characters (example: "1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"). Of course, you cannot use random hex strings. You must use the device tokens sent to you from the devices on which your app is installed.

You get an exception for the first non-hex character in your string, which happens v

.

+2


source







All Articles