1

I want to send Push notification using Coldfusion. I couldn't find much help on google. I could find only one article that discusses this topic. But unfortunately I am getting exceptions while following that method. As that method uses a JAR file, I am not able to debug the exception. Even I cannot see the exceptions.

I just want to know is there a simple way to send Push Notifications? Like there is one for Android. In Android you just have to send an http request and you're done. But I can see things are so complicated in case of Apple.

But I am sure that someone would have definitely achieved this. Can anyone please help me on this?

Finally from suggestions, I implemented onError in my Application.cfc and got the following error:

Could not initialize class com.rsa.jcm.c.br
ava.lang.NoClassDefFoundError: Could not initialize class com.rsa.jcm.c.br at
com.rsa.jcm.c.ch.g(Unknown Source) at com.rsa.jcm.c.ch.h(Unknown Source) at
com.rsa.jcm.c.ch.f(Unknown Source) at com.rsa.jcm.c.jt.newSymmetricCipher(Unknown Source) at
com.rsa.cryptoj.o.mu.newSymmetricCipher(Unknown Source) at com.rsa.cryptoj.o.an.d(Unknown Source) at com.rsa.cryptoj.o.li.<init>(Unknown Source) at com.rsa.cryptoj.o.hh.<init>(Unknown Source) at com.rsa.cryptoj.o.gu.<init>(Unknown Source) at com.rsa.cryptoj.o.cc$240.a(Unknown Source) at com.rsa.cryptoj.o.da.a(Unknown Source) at com.rsa.cryptoj.o.da.a(Unknown Source) at
com.rsa.cryptoj.o.gx.b(Unknown Source) at com.rsa.cryptoj.o.gx.a(Unknown Source) at
com.rsa.cryptoj.o.gx.a(Unknown Source) at com.rsa.cryptoj.o.gx.a(Unknown Source) at
com.rsa.cryptoj.o.gx.a(Unknown Source) at com.rsa.cryptoj.o.gx.engineLoad(Unknown Source) at java.security.KeyStore.load(KeyStore.java:1185) at
com.notnoop.apns.internal.Utilities.newSSLContext(Utilities.java:87) at
com.notnoop.apns.ApnsServiceBuilder.withCert(ApnsServiceBuilder.java:139) at
com.notnoop.apns.ApnsServiceBuilder.withCert(ApnsServiceBuilder.java:114) at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at
java.lang.reflect.Method.invoke(Method.java:597) at
coldfusion.runtime.StructBean.invoke(StructBean.java:508) at
coldfusion.runtime.CfJspPage._invoke(CfJspPage.java:2465) at

Edit:

CF Code:

<cfset APNSService = createObject( "java", "com.notnoop.apns.APNS" ).newService()
    .withCert("E:\WEB\mysite.com\login\JAR\DevPushCertificates.p12", "")
    .withSandboxDestination()
    .build() />

<!--- I get the exception here and the code bellow is not executed --->        

<cfset payload = createObject( "java", "com.notnoop.apns.APNS" ).newPayload()
    .badge(3)
    .alertBody("Hello, world.")
    .sound("PushNotification.caf")
    .build()/>

<cfset APNSService.push('#deviceToken#', payload) />

I am using this JAR file: https://github.com/notnoop/java-apns/downloads

I got it from this blog: http://www.raymondcamden.com/index.cfm/2010/9/13/Guest-Post-Apple-Push-Notifications-From-ColdFusion-in-Ten-Minutes-or-Less#c843ED990-C791-2A3E-1E9FD9B78ECADFF7

Adil Malik
  • 6,279
  • 7
  • 48
  • 77
  • You should see some exceptions in the /logs/exception.log file in ColdFusion. Is there anything there? Also, add a before your problematic code. It sometimes forces CF to dump errors out to the response, rather than producing no response at all – barnyr Apr 10 '13 at 13:07
  • @barnyr In fact my client is using a shared server. So, I don't have access to CFAdmin or Coldfusion directory. That's why I feel like blind and cannot debug with full freedom. :-( – Adil Malik Apr 10 '13 at 13:10
  • I was thinking someone would definitely have a working code for this. If someone can share that, that would be really helpful for me and others. – Adil Malik Apr 10 '13 at 13:11
  • I would suggest using the onError function in your application.cfc to catch and log exceptions yourself. In a shared environment especially. – Walter Bax Apr 10 '13 at 15:16
  • If possible, install CF on your machine, write a simple test case and observe the errors locally. It might seem like more work but CF can be installed in 15 minutes and you'll be able to debug your code properly – barnyr Apr 10 '13 at 16:07
  • @WalterBax on your suggestion, I've added the onError in Application.cfc and found the error details. I've added the error in OP. Can you please take a look if you can help with that? – Adil Malik Apr 10 '13 at 16:52
  • @barnyr - Hm.. is this the same SSL problem you mentioned over here: http://stackoverflow.com/questions/15929674/translate-from-php-to-coldfusion – Leigh Apr 10 '13 at 17:06
  • @Leigh same problem but different question. In that post my question was if I can make an SSL request without depending on any JAR files. As we can do in PHP. I got the answer `NO`. – Adil Malik Apr 10 '13 at 17:12
  • @AdilMalik - Exactly which jar file are you using? There are 11 on that linked page ;-) Also *how* are you loading them? – Leigh Apr 10 '13 at 17:36
  • The linked apns JAR (even the -with-dependencies one) does not contain any com.rsa classes. However you can see from the stack trace in the exception that some com.rsa.jcm.* classes are in use. This likely means that you're using an older version of a JAR somewhere. As @Leigh asks below, the next step is to look at how your jars are being loaded. My guess is that you're running into an older version of the JAR containing the com.rsa.jcm.* classes? – barnyr Apr 11 '13 at 08:40

2 Answers2

1

If you post that question at several location please add a link to the other copies of the questions.

Have a look at my answer to your java-apns issue on github.

(Updated with response from link)

This looks like a problem with ColdFusion. In the above stack dump you see:

    com.notnoop.apns.internal.Utilities.newSSLContext(Utilities.java:87)

calls into

    java.security.KeyStore.load(KeyStore.java:1185)

which in turn fails after some ruminations in the com.rsa.cryptoj library. So obviously something doesn't work with accessing the java key store in ColdFusion.

Googling for one of the classes in the error yields some interesting results:

Leigh
  • 28,765
  • 10
  • 55
  • 103
froh42
  • 5,190
  • 6
  • 30
  • 42
0

As my server is on shared hosting. So, for every single change, I had to submit a ticket to the hosting site. It was causing headache. Finally, I had the php server setup placed the push notification code (easily available in PHP on google) on PHP server. Then I called that php file from the Coldfusion code. This worked for me.

Adil Malik
  • 6,279
  • 7
  • 48
  • 77
  • @M.A You can find a lot of help on google. For example, look at this: http://codular.com/sending-ios-push-notifications-with-php – Adil Malik Jun 09 '17 at 20:00