1
1
package com .onesignal ;
2
2
3
3
import android .support .annotation .NonNull ;
4
+ import android .support .annotation .Nullable ;
4
5
5
6
import org .json .JSONArray ;
6
7
import org .json .JSONException ;
10
11
11
12
class OneSignalRemoteParams {
12
13
14
+ static class FCMParams {
15
+ @ Nullable String projectId ;
16
+ @ Nullable String appId ;
17
+ @ Nullable String apiKey ;
18
+ }
19
+
13
20
static class OutcomesParams {
14
21
//in minutes
15
22
int indirectAttributionWindow = DEFAULT_INDIRECT_ATTRIBUTION_WINDOW ;
@@ -29,6 +36,7 @@ static class Params {
29
36
boolean clearGroupOnSummaryClick ;
30
37
boolean receiveReceiptEnabled ;
31
38
OutcomesParams outcomesParams ;
39
+ FCMParams fcmParams ;
32
40
}
33
41
34
42
interface CallBack {
@@ -44,6 +52,11 @@ interface CallBack {
44
52
private static final String NOTIFICATION_ATTRIBUTION_PARAM = "notification_attribution" ;
45
53
private static final String UNATTRIBUTED_PARAM = "unattributed" ;
46
54
55
+ private static final String FCM_PARENT_PARAM = "fcm" ;
56
+ private static final String FCM_PROJECT_ID = "project_id" ;
57
+ private static final String FCM_APP_ID = "app_id" ;
58
+ private static final String FCM_API_KEY = "api_key" ;
59
+
47
60
private static final int INCREASE_BETWEEN_RETRIES = 10_000 ;
48
61
private static final int MIN_WAIT_BETWEEN_RETRIES = 30_000 ;
49
62
private static final int MAX_WAIT_BETWEEN_RETRIES = 90_000 ;
@@ -109,8 +122,8 @@ static private void processJson(String json, final @NonNull CallBack callBack) {
109
122
googleProjectNumber = responseJson .optString ("android_sender_id" , null );
110
123
clearGroupOnSummaryClick = responseJson .optBoolean ("clear_group_on_summary_click" , true );
111
124
receiveReceiptEnabled = responseJson .optBoolean ("receive_receipts_enable" , false );
112
- outcomesParams = new OutcomesParams ();
113
125
126
+ outcomesParams = new OutcomesParams ();
114
127
// Process outcomes params
115
128
if (responseJson .has (OUTCOME_PARAM )) {
116
129
JSONObject outcomes = responseJson .optJSONObject (OUTCOME_PARAM );
@@ -134,6 +147,14 @@ static private void processJson(String json, final @NonNull CallBack callBack) {
134
147
outcomesParams .unattributedEnabled = unattributed .optBoolean (ENABLED_PARAM );
135
148
}
136
149
}
150
+
151
+ fcmParams = new FCMParams ();
152
+ if (responseJson .has (FCM_PARENT_PARAM )) {
153
+ JSONObject fcm = responseJson .optJSONObject (FCM_PARENT_PARAM );
154
+ fcmParams .apiKey = fcm .optString (FCM_API_KEY , null );
155
+ fcmParams .appId = fcm .optString (FCM_APP_ID , null );
156
+ fcmParams .projectId = fcm .optString (FCM_PROJECT_ID , null );
157
+ }
137
158
}};
138
159
139
160
callBack .complete (params );
0 commit comments