CustomerGlu Notification
CustomerGlu sends notification as firebase data messages in the following formats

Using webview

If you would like to use the layouts from CG, you can extract the nudge url from data messages and load it in a webview
1
{
2
name: 'CustomerGlu',
3
data: {
4
"type": "CustomerGlu",
5
"glu_message_type":"in-app",
6
"title": "Attended live class X time(s)",
7
"body": "You are doing great! Just x more times to go and win your reward",
8
"image": "",
9
"nudge_url": "https://staging.d283eczxp8leqk.amplifyapp.com/program-nudge/streak-progress/?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiIyMzk3OTMiLCJjbGllbnQiOiI0ZjdmNjE5OC0yNGNmLTRkZDYtODcxOS04MjdkM2RlNzYwNGYiLCJpYXQiOjE2MTcwMTU3MDEsImV4cCI6MTY0ODU1MTcwMX0.sAoqC8TGw3SSFl3W7PvJJilLivD7tL3Y-n23iBWHXAU&campaignId=44941f5f-a84f-46c0-9901-6e80e445a257"
10
}
11
}
Copied!
Fullscreen nudge
Center interstitial nudge

Using Native In-app Layouts

If In-app layout already exists in the app, You can build the in-app notifications using he data messages we send. sample below
1
{
2
name: 'CustomerGlu',
3
notification: {
4
title: "Congrats!!",
5
body: "You're now 7 steps away from getting 10000 Bonus points! Click here to complete rest of the activities to earn $100"
6
},
7
data: {
8
data: "JSON NOTIFICATION OBJECT"
9
},
10
token: 'tempsdajhsadvvjhsdv'
11
}
Copied!

CustomerGlu Notification Object

1
{
2
"type": "CustomerGlu",
3
"glu_message_source": "",
4
"glu_user_id": "",
5
"glu_campaign_id": "",
6
"glu_message_type": "in-app",
7
"glu_push_message_content": {
8
"title": "Your friend just signed up",
9
"body": "Get all of your friends on here",
10
"image": "/assets/multi-step/mini-icons/7.png",
11
"cta_button_text": "Go To Challenge",
12
"cta_button_link": "/tasks?event=customerGlu&deepLink=",
13
"deeplink": "/tasks?event=customerGlu&deepLink="
14
},
15
"glu_inapp_message_content": {
16
"page_name": "",
17
"page_type": "middle-default",
18
"page_accent": "default",
19
"page_details": {
20
"title": "Your friend just signed up",
21
"body": "Get all of your friends on here",
22
"image": "/assets/multi-step/mini-icons/7.png",
23
"cta_button_text": "Go To Challenge",
24
"cta_button_link": "/tasks?event=customerGlu&deepLink="
25
}
26
}
27
}
28
}
Copied!

Handling CustomerGlu Notifications

Android (Java)
Android (Kotlin)
iOS (Swift)
1
@RequiresApi(api = Build.VERSION_CODES.M)
2
public static void displayCustomerGluNotification(Context context,JSONObject json,int icon) {
3
JSONObject data = null;
4
try {
5
data = new JSONObject(String.valueOf(json));
6
System.out.println(data);
7
String type = data.getString("type");
8
String in_app="";
9
String in_app_type="";
10
11
if(type.equalsIgnoreCase("CustomerGlu")) {
12
String url = data.getString("nudge_url");
13
String body = data.getString("body");
14
String title = data.getString("title");
15
String glu_message_type = data.getString("glu_message_type");
16
String image = data.getString("image");
17
if(data.has("inapp")) {
18
in_app = data.getString("inapp");
19
JSONObject in_app_object = new JSONObject(in_app);
20
in_app_type = in_app_object.getString("type");
21
}
22
23
if (glu_message_type.equalsIgnoreCase("in-app")) {
24
CustomerGlu.handleDataMessage(context,url,in_app_type);
25
}
26
else {
27
if(image.equalsIgnoreCase(""))
28
{
29
displayNotification(context, title, body, url,icon);
30
31
}
32
else {
33
displayExpandedNotification(context, title, body, url, image,icon);
34
}
35
}
36
}
37
else
38
{
39
return;
40
}
41
} catch (JSONException e) {
42
e.printStackTrace();
43
}
44
45
46
}
47
public static void handleDataMessage(Context context,String url,String type) {
48
49
System.out.println(type);
50
if(type.equalsIgnoreCase("bottom-slider"))
51
{
52
Intent intent = new Intent(context, BottomSheet.class);
53
intent.putExtra("nudge_url", url);
54
intent.setFlags(FLAG_ACTIVITY_NEW_TASK);
55
context.startActivity(intent);
56
}
57
else if(type.equalsIgnoreCase("bottom-default"))
58
{
59
Intent intent = new Intent(context, BottomDialog.class);
60
intent.putExtra("nudge_url", url);
61
intent.setFlags(FLAG_ACTIVITY_NEW_TASK);
62
context.startActivity(intent);
63
}
64
else if(type.equalsIgnoreCase("middle-default"))
65
{
66
Intent intent = new Intent(context, MiddleDialog.class);
67
intent.putExtra("nudge_url", url);
68
intent.setFlags(FLAG_ACTIVITY_NEW_TASK);
69
context.startActivity(intent);
70
}
71
72
else {
73
Intent intent = new Intent(context, NotificationWeb.class);
74
intent.putExtra("nudge_url", url);
75
intent.setFlags(FLAG_ACTIVITY_NEW_TASK);
76
context.startActivity(intent);
77
}
78
79
}
80
81
82
@RequiresApi(api = Build.VERSION_CODES.M)
83
public static void displayExpandedNotification(Context context, String title, String message, String url,String image,int icon) {
84
System.out.println("sdadsad");
85
System.out.println(url);
86
Intent intent = new Intent(context, NotificationWeb.class);
87
intent.setFlags(FLAG_ACTIVITY_NEW_TASK);
88
intent.putExtra("nudge_url",url);
89
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
90
91
Bitmap bmp = null;
92
try {
93
InputStream in = new URL(image).openStream();
94
bmp = BitmapFactory.decodeStream(in);
95
} catch (IOException e) {
96
e.printStackTrace();
97
}
98
NotificationCompat.Builder builder = new NotificationCompat.Builder(context, "234")
99
.setSmallIcon(icon)
100
.setContentTitle(Html.fromHtml(title))
101
.setContentText(Html.fromHtml(message))
102
.setAutoCancel(true)
103
.setContentIntent(pendingIntent)
104
.setPriority(PRIORITY_MAX)
105
.setLargeIcon(bmp)
106
.setStyle(new NotificationCompat.BigPictureStyle()
107
.bigPicture(bmp)
108
.bigLargeIcon(null))
109
.setDefaults(DEFAULT_ALL);
110
NotificationManager manager = context.getSystemService(NotificationManager.class);
111
112
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
113
@SuppressLint("WrongConstant") NotificationChannel notificationChannel = new NotificationChannel("234", "CustomerGlu", NotificationManager.IMPORTANCE_MAX);
114
115
manager.createNotificationChannel(notificationChannel);
116
}
117
manager.notify(Integer.parseInt(("234")), builder.build());
118
119
120
121
122
}
123
124
@RequiresApi(api = Build.VERSION_CODES.M)
125
public static void displayNotification(Context context, String title, String message, String url,int icon) {
126
System.out.println("sdadsad");
127
System.out.println(url);
128
Intent intent = new Intent(context, NotificationWeb.class);
129
intent.setFlags(FLAG_ACTIVITY_NEW_TASK);
130
intent.putExtra("nudge_url",url);
131
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
132
133
NotificationCompat.Builder builder = new NotificationCompat.Builder(context, "234")
134
.setSmallIcon(icon)
135
.setContentTitle(Html.fromHtml(title))
136
.setContentText(Html.fromHtml(message))
137
.setAutoCancel(true)
138
.setContentIntent(pendingIntent)
139
.setPriority(PRIORITY_MAX)
140
.setDefaults(DEFAULT_ALL);
141
NotificationManager manager = context.getSystemService(NotificationManager.class);
142
143
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
144
@SuppressLint("WrongConstant") NotificationChannel notificationChannel = new NotificationChannel("234", "CustomerGlu", NotificationManager.IMPORTANCE_MAX);
145
146
manager.createNotificationChannel(notificationChannel);
147
}
148
manager.notify(Integer.parseInt(("234")), builder.build());
149
150
151
152
153
}
Copied!
1
@RequiresApi(api = Build.VERSION_CODES.M)
2
public static void displayCustomerGluNotification(Context context,JSONObject json,int icon) {
3
JSONObject data = null;
4
try {
5
data = new JSONObject(String.valueOf(json));
6
System.out.println(data);
7
String type = data.getString("type");
8
String in_app="";
9
String in_app_type="";
10
11
if(type.equalsIgnoreCase("CustomerGlu")) {
12
String url = data.getString("nudge_url");
13
String body = data.getString("body");
14
String title = data.getString("title");
15
String glu_message_type = data.getString("glu_message_type");
16
String image = data.getString("image");
17
if(data.has("inapp")) {
18
in_app = data.getString("inapp");
19
JSONObject in_app_object = new JSONObject(in_app);
20
in_app_type = in_app_object.getString("type");
21
}
22
23
if (glu_message_type.equalsIgnoreCase("in-app")) {
24
CustomerGlu.handleDataMessage(context,url,in_app_type);
25
}
26
else {
27
if(image.equalsIgnoreCase(""))
28
{
29
displayNotification(context, title, body, url,icon);
30
31
}
32
else {
33
displayExpandedNotification(context, title, body, url, image,icon);
34
}
35
}
36
}
37
else
38
{
39
return;
40
}
41
} catch (JSONException e) {
42
e.printStackTrace();
43
}
44
45
46
}
47
public static void handleDataMessage(Context context,String url,String type) {
48
49
System.out.println(type);
50
if(type.equalsIgnoreCase("bottom-slider"))
51
{
52
Intent intent = new Intent(context, BottomSheet.class);
53
intent.putExtra("nudge_url", url);
54
intent.setFlags(FLAG_ACTIVITY_NEW_TASK);
55
context.startActivity(intent);
56
}
57
else if(type.equalsIgnoreCase("bottom-default"))
58
{
59
Intent intent = new Intent(context, BottomDialog.class);
60
intent.putExtra("nudge_url", url);
61
intent.setFlags(FLAG_ACTIVITY_NEW_TASK);
62
context.startActivity(intent);
63
}
64
else if(type.equalsIgnoreCase("middle-default"))
65
{
66
Intent intent = new Intent(context, MiddleDialog.class);
67
intent.putExtra("nudge_url", url);
68
intent.setFlags(FLAG_ACTIVITY_NEW_TASK);
69
context.startActivity(intent);
70
}
71
72
else {
73
Intent intent = new Intent(context, NotificationWeb.class);
74
intent.putExtra("nudge_url", url);
75
intent.setFlags(FLAG_ACTIVITY_NEW_TASK);
76
context.startActivity(intent);
77
}
78
79
}
80
81
82
@RequiresApi(api = Build.VERSION_CODES.M)
83
public static void displayExpandedNotification(Context context, String title, String message, String url,String image,int icon) {
84
System.out.println("sdadsad");
85
System.out.println(url);
86
Intent intent = new Intent(context, NotificationWeb.class);
87
intent.setFlags(FLAG_ACTIVITY_NEW_TASK);
88
intent.putExtra("nudge_url",url);
89
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
90
91
Bitmap bmp = null;
92
try {
93
InputStream in = new URL(image).openStream();
94
bmp = BitmapFactory.decodeStream(in);
95
} catch (IOException e) {
96
e.printStackTrace();
97
}
98
NotificationCompat.Builder builder = new NotificationCompat.Builder(context, "234")
99
.setSmallIcon(icon)
100
.setContentTitle(Html.fromHtml(title))
101
.setContentText(Html.fromHtml(message))
102
.setAutoCancel(true)
103
.setContentIntent(pendingIntent)
104
.setPriority(PRIORITY_MAX)
105
.setLargeIcon(bmp)
106
.setStyle(new NotificationCompat.BigPictureStyle()
107
.bigPicture(bmp)
108
.bigLargeIcon(null))
109
.setDefaults(DEFAULT_ALL);
110
NotificationManager manager = context.getSystemService(NotificationManager.class);
111
112
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
113
@SuppressLint("WrongConstant") NotificationChannel notificationChannel = new NotificationChannel("234", "CustomerGlu", NotificationManager.IMPORTANCE_MAX);
114
115
manager.createNotificationChannel(notificationChannel);
116
}
117
manager.notify(Integer.parseInt(("234")), builder.build());
118
119
120
121
122
}
123
124
@RequiresApi(api = Build.VERSION_CODES.M)
125
public static void displayNotification(Context context, String title, String message, String url,int icon) {
126
System.out.println("sdadsad");
127
System.out.println(url);
128
Intent intent = new Intent(context, NotificationWeb.class);
129
intent.setFlags(FLAG_ACTIVITY_NEW_TASK);
130
intent.putExtra("nudge_url",url);
131
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
132
133
NotificationCompat.Builder builder = new NotificationCompat.Builder(context, "234")
134
.setSmallIcon(icon)
135
.setContentTitle(Html.fromHtml(title))
136
.setContentText(Html.fromHtml(message))
137
.setAutoCancel(true)
138
.setContentIntent(pendingIntent)
139
.setPriority(PRIORITY_MAX)
140
.setDefaults(DEFAULT_ALL);
141
NotificationManager manager = context.getSystemService(NotificationManager.class);
142
143
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
144
@SuppressLint("WrongConstant") NotificationChannel notificationChannel = new NotificationChannel("234", "CustomerGlu", NotificationManager.IMPORTANCE_MAX);
145
146
manager.createNotificationChannel(notificationChannel);
147
}
148
manager.notify(Integer.parseInt(("234")), builder.build());
149
150
151
152
153
}
Copied!
1
//Checking if notification is from CustomerGlu
2
public func notificationFromCustomerGlu(remoteMessage:[String:AnyHashable])-> Bool {
3
let Type = remoteMessage["type"]
4
if Type as! String == "CustomerGlu"
5
{
6
if ((remoteMessage["glu_message_type"] as? String) == "in-app") {
7
return true
8
}
9
else
10
{
11
return false
12
}
13
}
14
else{
15
return false
16
}
17
}
18
19
//Handling the CG Notification
20
public func displayNotification(remoteMessage:[String:AnyHashable]) {
21
let nudge_url = remoteMessage["nudge_url"]
22
print(nudge_url as Any)
23
let notification_type = remoteMessage["notification_type"]
24
if ((remoteMessage["glu_message_type"] as? String) == "in-app") {
25
print(notification_type as Any)
26
if notification_type as! String == "bottom-slider"
27
{
28
let swiftUIView = NotificationHandler(my_url: nudge_url as! String)
29
let hostingController = UIHostingController(rootView: swiftUIView)
30
// hostingController.modalPresentationStyle = .fullScreen
31
guard let topController = UIViewController.topViewController() else {
32
return
33
}
34
topController.present(hostingController, animated: true, completion: nil)
35
}
36
else if notification_type as! String == "bottom-default"{
37
let swiftUIView = NotificationHandler(my_url: nudge_url as! String)
38
let hostingController = UIHostingController(rootView: swiftUIView)
39
// hostingController.modalPresentationStyle = .overFullScreen
40
hostingController.isModalInPresentation = true
41
guard let topController = UIViewController.topViewController() else {
42
return
43
}
44
topController.present(hostingController, animated: true, completion: nil) }
45
else if notification_type as! String == "middle-default"{
46
let swiftUIView = NotificationHandler(my_url: nudge_url as! String, ismiddle:true)
47
let hostingController = UIHostingController(rootView: swiftUIView)
48
hostingController.modalPresentationStyle = .overCurrentContext
49
hostingController.view.backgroundColor = .clear
50
guard let topController = UIViewController.topViewController() else {
51
return
52
}
53
topController.present(hostingController, animated: true, completion: nil)
54
}
55
else
56
{
57
let swiftUIView = NotificationHandler(my_url: nudge_url as! String)
58
let hostingController = UIHostingController(rootView: swiftUIView)
59
hostingController.modalPresentationStyle = .fullScreen
60
guard let topController = UIViewController.topViewController() else {
61
return
62
}
63
topController.present(hostingController, animated: true, completion: nil) }
64
}
65
else
66
{
67
return
68
}
69
}
Copied!

In-App Nudges Samples