-
Notifications
You must be signed in to change notification settings - Fork 30
/
IOSPush.java
29 lines (25 loc) · 1.05 KB
/
IOSPush.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import com.notnoop.apns.APNS;
import com.notnoop.apns.ApnsService;
public class IOSPush {
/**
* Replace DEVICE_TOKEN with your DEVICE_TOKEN
* Replace PATH_TO_P12_CERT with your YOUR_P12_CERTIFICATE_PATH
* Replace CERT_PASSWORD with your YOUR_P12_CERTIFICATE_PASSWORD
*/
private static String DEVICE_TOKEN = "YOUR_DEVICE_TOKEN";
private static String PATH_TO_P12_CERT = "YOUR_P12_CERTIFICATE_PATH";
private static String CERT_PASSWORD = "YOUR_P12_CERTIFICATE_PASSWORD";
public static void main(String[] args) {
ApnsService service =
APNS.newService()
.withCert(PATH_TO_P12_CERT, CERT_PASSWORD)
.withSandboxDestination()
.build();
String payload = APNS.newPayload()
.alertBody("My first notification\nHello, I'm push notification")
.sound("default")
.build();
service.push(DEVICE_TOKEN, payload);
System.out.println("The message has been hopefully sent...");
}
}