@@ -59,24 +59,26 @@ So the whole interface is asynchronous as well.
5959Every SDK method returns a promise, which resolves with the requested information or throws an error if something has gone wrong.
6060
6161``` js
62- PluginSDK .isIosDevice ().then (function (isIOS ) {
62+ PluginSDK .isIosDevice ()
63+ .then (function (isIOS ) {
6364 console .log (' IOS Device: ' , isIOS);
64- }).catch (function (error ) {
65- console .warn (' Something went wrong: ' , error)
66- })
65+ })
66+ .catch (function (error ) {
67+ console .warn (' Something went wrong: ' , error);
68+ });
6769```
6870
6971To get multiple informations at once, you can use ` Promise.all ` .
7072
7173``` js
7274Promise .all ([PluginSDK .isIosDevice (), PluginSDK .isNativeApp ()])
73- .then (function (isIOS , isNative ) {
74- console .log (' IOS Device: ' , isIOS);
75- console .log (' Native App: ' , isNative);
76- })
77- .catch (function (error ) {
78- console .warn (' Something went wrong: ' , error)
79- })
75+ .then (function (isIOS , isNative ) {
76+ console .log (' IOS Device: ' , isIOS);
77+ console .log (' Native App: ' , isNative);
78+ })
79+ .catch (function (error ) {
80+ console .warn (' Something went wrong: ' , error);
81+ });
8082```
8183
8284### Getting infos from the Staffbase app
@@ -171,8 +173,18 @@ As a developer you can request various informations from the Staffbase app.
171173 ``` js
172174 // example for user with german content locale in an english app
173175 getUserContentLocale ().then (function (locale ) {
174- console .log (locale); // 'de_DE'
175- })
176+ console .log (locale); // 'de_DE'
177+ });
178+ ```
179+
180+ 1 . ` getInstanceUrl ` -> string
181+
182+ the URL of the Staffbase instance (frontend domain) the plugin is embedded in
183+
184+ ``` js
185+ getInstanceUrl ().then (function (url ) {
186+ console .log (url); // 'https://customer.staffbase.com'
187+ });
176188 ```
177189
178190### Invoking native methods
@@ -184,16 +196,16 @@ With the SDK you can invoke methods, which are in the scope of the native app.
184196 checks a given list of locale tags, or an object with locale tags as keys and returns the matching locale tag as string.
185197
186198 ``` js
187- const localesArray = [' de_DE' , ' en_US' ];
188- const localesObject = { ' de_DE' : {}, ' en_US' : {} };
199+ const localesArray = [' de_DE' , ' en_US' ];
200+ const localesObject = { de_DE: {}, en_US: {} };
189201
190- getPreferredContentLocale (localesArray).then (function (locale ) {
191- console .log (locale); // 'en_US'
192- })
202+ getPreferredContentLocale (localesArray).then (function (locale ) {
203+ console .log (locale); // 'en_US'
204+ });
193205
194- getPreferredContentLocale (localesObject).then (function (locale ) {
195- console .log (locale); // 'en_US'
196- })
206+ getPreferredContentLocale (localesObject).then (function (locale ) {
207+ console .log (locale); // 'en_US'
208+ });
197209 ```
198210
1992112 . ` openLink ` {url: string} -> boolean
@@ -202,56 +214,58 @@ With the SDK you can invoke methods, which are in the scope of the native app.
202214 which indicates if the link has been opened. This can be used to call the method in a click event
203215
204216 ``` js
205- // internal link
206- openLink (' /settings/password' ).then (function (opened ) {
207- console .log (opened); // true
208- })
209-
210- // external link
211- openLink (' https://staffbase.com' ).then (function (opened ) {
212- console .log (opened); // true
213- })
217+ // internal link
218+ openLink (' /settings/password' ).then (function (opened ) {
219+ console .log (opened); // true
220+ });
221+
222+ // external link
223+ openLink (' https://staffbase.com' ).then (function (opened ) {
224+ console .log (opened); // true
225+ });
214226 ```
215227
2162283 . ` openLinkExternal ` {url: string} -> boolean
217229
218230 open a link in the device browser. Returns a boolean which indicates if the link has been opened. This can be used to call the method in a click event
219231
220232 ``` js
221- // external link
222- openLinkExternal (' https://staffbase.com' ).then (function (opened ) {
223- console .log (opened); // true
224- })
233+ // external link
234+ openLinkExternal (' https://staffbase.com' ).then (function (opened ) {
235+ console .log (opened); // true
236+ });
225237 ```
226238
2272394 . ` openLinkInternal ` {url: string} -> boolean
228240
229241 open a link in the app browser. Returns a boolean which indicates if the link has been opened. This can be used to call the method in a click event
230242
231243 ``` js
232- // external link
233- openLinkInternal (' https://staffbase.com' ).then (function (opened ) {
234- console .log (opened); // true
235- })
244+ // external link
245+ openLinkInternal (' https://staffbase.com' ).then (function (opened ) {
246+ console .log (opened); // true
247+ });
236248 ```
237249
2382505 . ` openNativeShareDialog ` {content: object} -> string
239251
240252 - ** native only**
241253 - ** version > 4.0.0**
242254
243- open the native share view to share an object consisting of an image link, subject, text or url.
244-
245- ``` js
246- const contentObject = {image: " https://example.com/test.png" ,
247- subject: " The string you would like to use as a subject for the share" ,
248- text: " This text is shared" ,
249- url: " https://example.com" };
255+ open the native share view to share an object consisting of an image link, subject, text or url.
250256
251- openNativeShareDialog (contentObject).then (function (opened ) {
252- console .log (opened); // true
253- })
254- ```
257+ ``` js
258+ const contentObject = {
259+ image: ' https://example.com/test.png' ,
260+ subject: ' The string you would like to use as a subject for the share' ,
261+ text: ' This text is shared' ,
262+ url: ' https://example.com'
263+ };
264+
265+ openNativeShareDialog (contentObject).then (function (opened ) {
266+ console .log (opened); // true
267+ });
268+ ```
255269
2562706 . ` openNativeFileDialog ` -> Blob ** !experimental**
257271
@@ -263,7 +277,7 @@ With the SDK you can invoke methods, which are in the scope of the native app.
263277 > Attention! This function is still in development and will have a changed behavior in the future!
264278
265279 ``` js
266- openNativeFileDialog ().then(function (res) {
267- console .log (' Fileurl: ' + URL .createObjectURL (res)); // blob:d3958f5c-0777-0845-9dcf-2cb28783acaf
268- })
280+ openNativeFileDialog ().then (function (res ) {
281+ console .log (' Fileurl: ' + URL .createObjectURL (res)); // blob:d3958f5c-0777-0845-9dcf-2cb28783acaf
282+ });
269283 ```
0 commit comments