7

I have an application built in hybrid framework. It is totally built with usning REST APIs from salesforce. I can't use SDK here. Please suggest how to write a trigger or webservice to initiate push notification for iOS devices.

How to call ssl end point of apple: ssl://gateway.sandbox.push.apple.com:2195

How to include apple .pem certificate while in HTTP request from salesforce to APNS.


EDITED: I have converted my .p12 certificate to jks and uploaded on salesforce and used in http request. Have a look on code below:

Http http = new Http();
HttpRequest req = new HttpRequest();
req.setEndpoint('https://gateway.sandbox.push.apple.com:2195');
req.setMethod('GET');
req.setClientCertificateName('distributioncertificate');
//req.setCompressed(false);
HttpResponse res = http.send(req);
System.debug(res.getBody());

But when I run this code it gives an error

enter image description here

Please suggest how I can connect with APNS endpoint without any error.

5
  • You are trying to push an object data to URL in JSON format right? Nov 18, 2015 at 15:46
  • I am trying to send JSON data Dec 2, 2015 at 13:22
  • if you trying to send data then use post why you are using get method?
    – Ratan Paul
    Dec 2, 2015 at 13:33
  • @Ratan: I have tried POST as well; it gives same result Dec 2, 2015 at 13:44
  • does anybody has the solution for above situation? please post if you have some workarounds to handle the above situation.
    – Suri
    Jan 17, 2017 at 0:55

2 Answers 2

1

The only way to do this is to create a separate connected app in Salesforce selecting Push Notification environment as APNS.

From membercenter you need to download a p12 certificate and upload in the connected application section. After that you can use Salesforce internal class to send the push notifications.

No custom approach is there to send push notifications to apple devices.

0

There are many repeated articles about the same issue and have marked best answers. e.g.

https://developer.salesforce.com/forums/?id=906F0000000ArfTIAS

This below code is in Java, however it is about the same issue. They were facing it because of the p12 certificate and resolved it by generating it properly.

https://stackoverflow.com/questions/29114912/push-notification-is-not-sent-to-apple-devices

https://stackoverflow.com/questions/12585858/cannot-send-push-notifications-using-javapns-javaapns-ssl-handshake-failure

1
  • These links are of no use in regard to my question. I am not looking for connected app approach. I want to create custom approach Dec 8, 2015 at 18:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.