Skip to content

Commit beae3f5

Browse files
committed
SHK-6622: Shake push notifications for Android and iOS
1 parent df82e71 commit beae3f5

25 files changed

Lines changed: 1888 additions & 253 deletions
Lines changed: 263 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,263 @@
1+
{
2+
"project_info": {
3+
"project_number": "517188204861",
4+
"firebase_url": "https://shake-bugs.firebaseio.com",
5+
"project_id": "shake-bugs",
6+
"storage_bucket": "shake-bugs.appspot.com"
7+
},
8+
"client": [
9+
{
10+
"client_info": {
11+
"mobilesdk_app_id": "1:517188204861:android:f3fa840d05a895cf04ad54",
12+
"android_client_info": {
13+
"package_name": "com.shakebugs.android"
14+
}
15+
},
16+
"oauth_client": [
17+
{
18+
"client_id": "517188204861-cnnnvpbn89s5eco4umvkaudbantqv8ai.apps.googleusercontent.com",
19+
"client_type": 3
20+
}
21+
],
22+
"api_key": [
23+
{
24+
"current_key": "AIzaSyCVT9qXrunk1mZw2baUTbow0uxzbMt9S8E"
25+
}
26+
],
27+
"services": {
28+
"appinvite_service": {
29+
"other_platform_oauth_client": [
30+
{
31+
"client_id": "117674586072430494119",
32+
"client_type": 3
33+
},
34+
{
35+
"client_id": "517188204861-029hl86b5nq3vp6hmbc7pt9dgct5cmke.apps.googleusercontent.com",
36+
"client_type": 2,
37+
"ios_info": {
38+
"bundle_id": "com.shakebugs.react.example.rc"
39+
}
40+
}
41+
]
42+
}
43+
}
44+
},
45+
{
46+
"client_info": {
47+
"mobilesdk_app_id": "1:517188204861:android:787bc6150b4ddb5704ad54",
48+
"android_client_info": {
49+
"package_name": "com.shakebugs.android.localhost"
50+
}
51+
},
52+
"oauth_client": [
53+
{
54+
"client_id": "517188204861-cnnnvpbn89s5eco4umvkaudbantqv8ai.apps.googleusercontent.com",
55+
"client_type": 3
56+
}
57+
],
58+
"api_key": [
59+
{
60+
"current_key": "AIzaSyCVT9qXrunk1mZw2baUTbow0uxzbMt9S8E"
61+
}
62+
],
63+
"services": {
64+
"appinvite_service": {
65+
"other_platform_oauth_client": [
66+
{
67+
"client_id": "117674586072430494119",
68+
"client_type": 3
69+
},
70+
{
71+
"client_id": "517188204861-029hl86b5nq3vp6hmbc7pt9dgct5cmke.apps.googleusercontent.com",
72+
"client_type": 2,
73+
"ios_info": {
74+
"bundle_id": "com.shakebugs.react.example.rc"
75+
}
76+
}
77+
]
78+
}
79+
}
80+
},
81+
{
82+
"client_info": {
83+
"mobilesdk_app_id": "1:517188204861:android:3e502aac19a3cc6204ad54",
84+
"android_client_info": {
85+
"package_name": "com.shakebugs.android.pr"
86+
}
87+
},
88+
"oauth_client": [
89+
{
90+
"client_id": "517188204861-cnnnvpbn89s5eco4umvkaudbantqv8ai.apps.googleusercontent.com",
91+
"client_type": 3
92+
}
93+
],
94+
"api_key": [
95+
{
96+
"current_key": "AIzaSyCVT9qXrunk1mZw2baUTbow0uxzbMt9S8E"
97+
}
98+
],
99+
"services": {
100+
"appinvite_service": {
101+
"other_platform_oauth_client": [
102+
{
103+
"client_id": "117674586072430494119",
104+
"client_type": 3
105+
},
106+
{
107+
"client_id": "517188204861-029hl86b5nq3vp6hmbc7pt9dgct5cmke.apps.googleusercontent.com",
108+
"client_type": 2,
109+
"ios_info": {
110+
"bundle_id": "com.shakebugs.react.example.rc"
111+
}
112+
}
113+
]
114+
}
115+
}
116+
},
117+
{
118+
"client_info": {
119+
"mobilesdk_app_id": "1:517188204861:android:117d4a86bca8b0d504ad54",
120+
"android_client_info": {
121+
"package_name": "com.shakebugs.android.rc"
122+
}
123+
},
124+
"oauth_client": [
125+
{
126+
"client_id": "517188204861-cnnnvpbn89s5eco4umvkaudbantqv8ai.apps.googleusercontent.com",
127+
"client_type": 3
128+
}
129+
],
130+
"api_key": [
131+
{
132+
"current_key": "AIzaSyCVT9qXrunk1mZw2baUTbow0uxzbMt9S8E"
133+
}
134+
],
135+
"services": {
136+
"appinvite_service": {
137+
"other_platform_oauth_client": [
138+
{
139+
"client_id": "117674586072430494119",
140+
"client_type": 3
141+
},
142+
{
143+
"client_id": "517188204861-029hl86b5nq3vp6hmbc7pt9dgct5cmke.apps.googleusercontent.com",
144+
"client_type": 2,
145+
"ios_info": {
146+
"bundle_id": "com.shakebugs.react.example.rc"
147+
}
148+
}
149+
]
150+
}
151+
}
152+
},
153+
{
154+
"client_info": {
155+
"mobilesdk_app_id": "1:517188204861:android:787e21d7a1c0e8bc04ad54",
156+
"android_client_info": {
157+
"package_name": "com.shakebugs.react.example"
158+
}
159+
},
160+
"oauth_client": [
161+
{
162+
"client_id": "517188204861-cnnnvpbn89s5eco4umvkaudbantqv8ai.apps.googleusercontent.com",
163+
"client_type": 3
164+
}
165+
],
166+
"api_key": [
167+
{
168+
"current_key": "AIzaSyCVT9qXrunk1mZw2baUTbow0uxzbMt9S8E"
169+
}
170+
],
171+
"services": {
172+
"appinvite_service": {
173+
"other_platform_oauth_client": [
174+
{
175+
"client_id": "117674586072430494119",
176+
"client_type": 3
177+
},
178+
{
179+
"client_id": "517188204861-029hl86b5nq3vp6hmbc7pt9dgct5cmke.apps.googleusercontent.com",
180+
"client_type": 2,
181+
"ios_info": {
182+
"bundle_id": "com.shakebugs.react.example.rc"
183+
}
184+
}
185+
]
186+
}
187+
}
188+
},
189+
{
190+
"client_info": {
191+
"mobilesdk_app_id": "1:517188204861:android:cee5743b5fd3cb9204ad54",
192+
"android_client_info": {
193+
"package_name": "com.shakebugs.react.example.pr"
194+
}
195+
},
196+
"oauth_client": [
197+
{
198+
"client_id": "517188204861-cnnnvpbn89s5eco4umvkaudbantqv8ai.apps.googleusercontent.com",
199+
"client_type": 3
200+
}
201+
],
202+
"api_key": [
203+
{
204+
"current_key": "AIzaSyCVT9qXrunk1mZw2baUTbow0uxzbMt9S8E"
205+
}
206+
],
207+
"services": {
208+
"appinvite_service": {
209+
"other_platform_oauth_client": [
210+
{
211+
"client_id": "117674586072430494119",
212+
"client_type": 3
213+
},
214+
{
215+
"client_id": "517188204861-029hl86b5nq3vp6hmbc7pt9dgct5cmke.apps.googleusercontent.com",
216+
"client_type": 2,
217+
"ios_info": {
218+
"bundle_id": "com.shakebugs.react.example.rc"
219+
}
220+
}
221+
]
222+
}
223+
}
224+
},
225+
{
226+
"client_info": {
227+
"mobilesdk_app_id": "1:517188204861:android:95b81a0e7a4e8b8804ad54",
228+
"android_client_info": {
229+
"package_name": "com.shakebugs.react.example.rc"
230+
}
231+
},
232+
"oauth_client": [
233+
{
234+
"client_id": "517188204861-cnnnvpbn89s5eco4umvkaudbantqv8ai.apps.googleusercontent.com",
235+
"client_type": 3
236+
}
237+
],
238+
"api_key": [
239+
{
240+
"current_key": "AIzaSyCVT9qXrunk1mZw2baUTbow0uxzbMt9S8E"
241+
}
242+
],
243+
"services": {
244+
"appinvite_service": {
245+
"other_platform_oauth_client": [
246+
{
247+
"client_id": "117674586072430494119",
248+
"client_type": 3
249+
},
250+
{
251+
"client_id": "517188204861-029hl86b5nq3vp6hmbc7pt9dgct5cmke.apps.googleusercontent.com",
252+
"client_type": 2,
253+
"ios_info": {
254+
"bundle_id": "com.shakebugs.react.example.rc"
255+
}
256+
}
257+
]
258+
}
259+
}
260+
}
261+
],
262+
"configuration_version": "1"
263+
}

android/src/main/java/com/shakebugs/react/ShakeModule.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import com.shakebugs.shake.ShakeReportConfiguration;
2727
import com.shakebugs.shake.ShakeScreen;
2828
import com.shakebugs.shake.actions.ShakeHomeAction;
29+
import com.shakebugs.shake.chat.ChatNotification;
2930
import com.shakebugs.shake.chat.UnreadChatMessagesListener;
3031
import com.shakebugs.shake.form.ShakeForm;
3132
import com.shakebugs.shake.internal.domain.models.NetworkRequest;
@@ -593,6 +594,22 @@ public void run() {
593594
});
594595
}
595596

597+
@ReactMethod
598+
public void setPushNotificationsToken(final String token) {
599+
runOnUiThread(new Runnable() {
600+
@Override
601+
public void run() {
602+
Shake.setPushNotificationsToken(token);
603+
}
604+
});
605+
}
606+
607+
@ReactMethod
608+
public void showChatNotification(final ReadableMap notificationData) {
609+
ChatNotification chatNotification = mapper.mapToChatNotification(notificationData);
610+
Shake.showChatNotification(chatNotification);
611+
}
612+
596613
@ReactMethod
597614
public void addListener(String eventName) {
598615
// Keep: Required for RN built in Event Emitter Calls.

android/src/main/java/com/shakebugs/react/utils/Mapper.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import com.shakebugs.shake.actions.ShakeHomeAction;
2222
import com.shakebugs.shake.actions.ShakeHomeChatAction;
2323
import com.shakebugs.shake.actions.ShakeHomeSubmitAction;
24+
import com.shakebugs.shake.chat.ChatNotification;
2425
import com.shakebugs.shake.form.ShakeAttachments;
2526
import com.shakebugs.shake.form.ShakeEmail;
2627
import com.shakebugs.shake.form.ShakeForm;
@@ -450,6 +451,24 @@ public Map<String, String> mapToUserMetadata(ReadableMap metadata) {
450451
return stringMap;
451452
}
452453

454+
public ChatNotification mapToChatNotification(ReadableMap notificationData) {
455+
ChatNotification chatNotification = null;
456+
457+
try {
458+
String id = notificationData.getString("id");
459+
String userId = notificationData.getString("userId");
460+
String title = notificationData.getString("title");
461+
String message = notificationData.getString("message");
462+
463+
if (id != null && userId != null && title != null && message != null) {
464+
chatNotification = new ChatNotification(id, userId, title, message);
465+
}
466+
} catch (Exception ignore) {
467+
}
468+
469+
return chatNotification;
470+
}
471+
453472
private Map<String, Object> toMap(ReadableMap readableMap) {
454473

455474
Map<String, Object> map = new HashMap<>();

0 commit comments

Comments
 (0)