Search code examples
javacoldfusionapple-push-notificationscoldfusion-8javapns

Why can't I call java-apns getInactiveDevices() method in ColdFusion 8?


I'm building an application to send push notifications to Apple devices from ColdFusion 8 using notnoop's java-apns library, and when calling a method in the library, I'm receiving "method not found" exception, even though the method is clearly defined in the library (line 161). I am able to send push notifications successfully, just this one method is not working. What is possibly wrong here???

Code:

<cfscript>
    LOCAL.APNSService =
        CreateObject("java", "com.notnoop.apns.APNS").newService()
            .withCert(
                "MyCert.p12",
                "MyPassword"
                )
            .withProductionDestination()
            .build();

    LOCAL.APNSService.start();
    LOCAL.InactiveDevices = LOCAL.APNSService.getInactiveDevices();

    LOCAL.payload =
        CreateObject("java", "com.notnoop.apns.APNS").newPayload()
            .badge(1)
            .alertBody("Hello, world.")
            .sound("PushNotification.caf")
            .build();

    LOCAL.APNSNotification =
        CreateObject("java", "com.notnoop.apns.SimpleApnsNotification")
            .init(
                JavaCast("string", LOCAL.MyDeviceToken),
                JavaCast("string", LOCAL.payload)
                );
    LOCAL.APNSService.push(LOCAL.APNSNotification);

    LOCAL.APNSService.stop();
</cfscript>

Exception:

The getInactiveDevices method was not found.

Stack Trace:

coldfusion.runtime.java.MethodSelectionException: The getInactiveDevices method was not found.
at coldfusion.runtime.java.ObjectHandler.findMethodUsingCFMLRules(ObjectHandler.java:322)
at coldfusion.runtime.StructBean.invoke(StructBean.java:527)
at coldfusion.runtime.CfJspPage._invoke(CfJspPage.java:2300)

Solution

  • Benn Linger created this workaround: http://www.bennlinger.com/uploads/get_inactive_devices.txt