Please suggest me, As iam having developement p12 file and dependencies But iam getting Exceptiopn when sending notification through Developement Certificate.p12 file. the Exception is (javax.net.ssl.SSLException) javax.net.ssl.SSLException: Received fatal alert: internal_error
package com.push.notification.server;
import com.notnoop.apns.APNS;
import com.notnoop.apns.ApnsService;
import com.notnoop.apns.EnhancedApnsNotification;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Date;
public class ApnsTest {
private ApnsService service;
public ApnsTest() {
try {
String path = "p12 file name";
File certFile = new File(path);
InputStream fis = new FileInputStream(certFile);
service = APNS.newService().withCert(fis, "pwd")
.withSandboxDestination()
.build();
sendMessage();
} catch (Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
new ApnsTest();
}
public void sendMessage() {
String payload = APNS.newPayload().alertBody("nnnnn").sound("default").build();
String deviceToken = "267fe9f23984cc6d8ca7b35db3c4b829cdbe2f9f1dbd3258cbbfa8f94e3fd986";
int now = (int) (new Date().getTime() / 1000);
EnhancedApnsNotification notification = new EnhancedApnsNotification(EnhancedApnsNotification.INCREMENT_ID(),
now + 60 * 60, deviceToken, payload);
System.out.println("Sending push notification");
try {
service.push(deviceToken, payload);
} catch (Exception e) {
e.printStackTrace();
}
}
}
Yes, above problem solved by Creating Development certificate once again.
This is procedure enter image description here first in On your Mac, open Keychain Access
From the top menu, select
Keychain Access > Certificate Assistant > Request a Certificate From a Certificate Authority…
Fill out your email address, common name Check Save to disk Press Continue and save the .certSigningRequest file somewhere enter image description here
Configuring Push Notifications for the App ID Once the APP ID registration is completed, you need to configure it to make to work with push notification. [enter image description here][3] Select the App ID you just created, and click Edit At Push Notifications, click Create Certificate then **Continue Click Choose File… and upload the .certSigningRequest file you have generated and saved on your Mac earlier. Click Generate. Once the certificate was generated, download it onto your Mac [enter image description here][4] 1.4 Creating a Private Key Now you are going to create a private key from the downloaded certificate. [enter image description here][5] Double-click the downloaded file. It should open in Keychain Access Select My Certificates at left. You should find the certificate you just added. Control-click the certificate, and select Export “Apple Development IOS Push Services:…”… Save it as ..p12 file, by selecting File Format as Personal Information Exchange (.p12) in the Save As dialog
1.5 Creating a Provisioning Profile on Apple Developer portal,
Go to Provisioning Profiles
Click + to create a new provisioning file
Select iOS App Development, then Continue
Select a correct App ID from the drop-down list, then Continue
Select a correct certificate from the list, then Continue
Select devices you are going to develop with, the Continue
Enter a name for the provisioning profile, then Generate
Download the file
Double-click open the file in Xcode. The profile now should be added to Xcode.