質問編集履歴
1
ソース微修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -32,29 +32,37 @@
|
|
32
32
|
|
33
33
|
public void run() {
|
34
34
|
|
35
|
-
St
|
35
|
+
JSONObject jsonMain = new JSONObject();
|
36
|
+
|
37
|
+
JSONObject jsonNotification = new JSONObject();
|
38
|
+
|
39
|
+
JSONObject jsonData = new JSONObject();
|
40
|
+
|
41
|
+
try {
|
42
|
+
|
43
|
+
jsonMain.put("to", "abc~~~");//送り先のtokenID
|
36
44
|
|
37
45
|
|
38
46
|
|
39
|
-
json.
|
47
|
+
jsonNotification.put("title", "Notification Title");
|
40
48
|
|
41
|
-
json.
|
49
|
+
jsonNotification.put("body", "Notification Body");
|
42
50
|
|
43
|
-
json.
|
51
|
+
jsonMain.put("notification", jsonNotification);
|
44
52
|
|
45
|
-
json.append("title : たいとる,");
|
46
53
|
|
47
|
-
json.append("body : 本文");
|
48
54
|
|
49
|
-
json.
|
55
|
+
jsonData.put("title", "Data Payload Title");
|
50
56
|
|
51
|
-
json.
|
57
|
+
jsonData.put("body", "Data Payload Body");
|
52
58
|
|
53
|
-
json.
|
59
|
+
jsonMain.put("data", jsonData);
|
54
60
|
|
55
|
-
|
61
|
+
} catch (JSONException e) {
|
56
62
|
|
57
|
-
|
63
|
+
e.printStackTrace();
|
64
|
+
|
65
|
+
}
|
58
66
|
|
59
67
|
|
60
68
|
|
@@ -76,7 +84,7 @@
|
|
76
84
|
|
77
85
|
|
78
86
|
|
79
|
-
byte[] outputBytes = json.toString().getBytes("UTF-8");
|
87
|
+
byte[] outputBytes = jsonMain .toString().getBytes("UTF-8");
|
80
88
|
|
81
89
|
OutputStream os = httpcon.getOutputStream();
|
82
90
|
|