forked from ringcentral/pubnub-jtools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPnApnsMessage.java
More file actions
84 lines (67 loc) · 1.65 KB
/
PnApnsMessage.java
File metadata and controls
84 lines (67 loc) · 1.65 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
package com.pubnub.api;
import org.json.JSONException;
import org.json.JSONObject;
/**
* Message object for APNS
* @author Pubnub
*
*/
public class PnApnsMessage extends JSONObject {
/**
* Constructor for APNS message object
*/
public PnApnsMessage() {
super();
}
private JSONObject getAps() {
JSONObject aps = null;
try {
aps = (JSONObject) this.get("aps");
} catch (JSONException e) {
}
if (aps == null) {
aps = new JSONObject();
try {
this.put("aps", aps);
} catch (JSONException e) {
}
}
return aps;
}
/**
* Set value of APS alert
* @param alert
* String to be set as alert value for APNS message
*/
public void setApsAlert(String alert) {
try {
JSONObject aps = (JSONObject) getAps();
aps.put("alert", alert);
} catch (JSONException e) {
}
}
/**
* Set value of APS badge
* @param badge
* int to be set as badge value for APNS message
*/
public void setApsBadge(int badge) {
try {
JSONObject aps = (JSONObject) (JSONObject) getAps();
aps.put("badge", badge);
} catch (JSONException e) {
}
}
/**
* Set value of APS sound
* @param sound
* String to be set as sound value for APNS message
*/
public void setApsSound(String sound) {
try {
JSONObject aps = (JSONObject) getAps();
aps.put("sound", sound);
} catch (JSONException e) {
}
}
}