@@ -47,7 +47,8 @@ public void onCreate( Object context )
47
47
48
48
public String getApplicationId ()
49
49
{
50
- return getAuthKeys ().getApplicationId ();
50
+ final AuthKeys authKeys = getAuthKeys ();
51
+ return authKeys == null ? null : authKeys .getApplicationId ();
51
52
}
52
53
53
54
public String getApiKey ()
@@ -78,6 +79,30 @@ public String getUrl()
78
79
return this .url ;
79
80
}
80
81
82
+ public AndroidBackendlessPrefs setCustomDomain ( String customDomain )
83
+ {
84
+ if ( sharedPreferences == null )
85
+ throw new IllegalStateException ( ExceptionMessage .NOT_INITIALIZED );
86
+
87
+ SharedPreferences .Editor editor = sharedPreferences .edit ();
88
+ editor .putString ( Type .CUSTOM_DOMAIN_KEY .name64 (), customDomain );
89
+ editor .commit ();
90
+
91
+ this .customDomain = customDomain ;
92
+ return this ;
93
+ }
94
+
95
+ public String getCustomDomain ()
96
+ {
97
+ if ( sharedPreferences == null )
98
+ throw new IllegalStateException ( ExceptionMessage .NOT_INITIALIZED );
99
+
100
+ if ( this .customDomain == null )
101
+ this .customDomain = sharedPreferences .getString ( Type .CUSTOM_DOMAIN_KEY .name64 (), Backendless .getUrl () );
102
+
103
+ return this .customDomain ;
104
+ }
105
+
81
106
public synchronized Map getHeaders ()
82
107
{
83
108
if ( headers == null )
@@ -90,7 +115,7 @@ private boolean restoreHeadersFromPreferences()
90
115
{
91
116
if ( sharedPreferences == null )
92
117
throw new IllegalStateException ( ExceptionMessage .NOT_INITIALIZED );
93
-
118
+
94
119
String rawHeaders = sharedPreferences .getString ( Type .HEADERS .name64 (), null );
95
120
96
121
if ( rawHeaders != null )
@@ -115,7 +140,7 @@ private synchronized AuthKeys getAuthKeys()
115
140
if ( authKeys == null )
116
141
restoreAuthKeysFromPreferences ();
117
142
118
- if ( authKeys == null )
143
+ if ( authKeys == null && getCustomDomain () == null )
119
144
throw new IllegalStateException ( ExceptionMessage .NOT_INITIALIZED );
120
145
121
146
return authKeys ;
@@ -125,7 +150,7 @@ private boolean restoreAuthKeysFromPreferences()
125
150
{
126
151
if ( sharedPreferences == null )
127
152
throw new IllegalStateException ( ExceptionMessage .NOT_INITIALIZED );
128
-
153
+
129
154
String applicationId = sharedPreferences .getString ( Type .APPLICATION_ID_KEY .name64 (), null );
130
155
String apiKey = sharedPreferences .getString ( Type .API_KEY .name64 (), null );
131
156
@@ -165,7 +190,7 @@ private void cleanHeadersFromPreferences()
165
190
{
166
191
if ( sharedPreferences == null )
167
192
throw new IllegalStateException ( ExceptionMessage .NOT_INITIALIZED );
168
-
193
+
169
194
if ( sharedPreferences .contains ( Type .HEADERS .name64 () ) )
170
195
{
171
196
SharedPreferences .Editor editor = sharedPreferences .edit ();
@@ -203,6 +228,7 @@ enum Type
203
228
APPLICATION_ID_KEY ,
204
229
API_KEY ,
205
230
URL_KEY ,
231
+ CUSTOM_DOMAIN_KEY ,
206
232
HEADERS ,
207
233
PUSH_TEMPLATES ,
208
234
NOTIFICATION_ID_GENERATOR ;
0 commit comments