forked from Raudius/Pushraven
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Sample.java
50 lines (34 loc) · 1.04 KB
/
Sample.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package com.pushraven;
import java.util.HashMap;
public class Sample {
private static String SERVER_KEY = "";
public static void main(String[] args) {
SERVER_KEY = args[0];
Pushraven.setKey(SERVER_KEY);
// create Notification object
Notification raven = new Notification();
HashMap<String, Object> data = new HashMap<String, Object>();
data.put("Hello", "World!");
data.put("Marco", "Polo");
data.put("Foo", "Bar");
// build raven message using the builder pattern
raven.to("news")
.collapse_key("a_collapse_key")
.priority(1)
.delay_while_idle(true)
.time_to_live(100)
.restricted_package_name("com.revihx.pushnot")
.dry_run(true)
.data(data)
.title("Testing")
.body("Hello World!")
.color("#ff0000");
// push the raven message
FcmResponse response = Pushraven.push(raven);
// alternatively set static notification first.
Pushraven.setNotification(raven);
response = Pushraven.push();
// prints response code and message
System.out.println(response);
}
}