natively 2.13.2 → 2.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -93,14 +93,12 @@ window.natively = {
93
93
  $agent.trigger(method, body);
94
94
  },
95
95
 
96
- openLogger: function () {
96
+ openLogger: function () { // DEPRECATED after 2.14.0
97
97
  $agent.natively_logger();
98
98
  },
99
99
 
100
- // Not available right now
101
100
  openConsole: function () {
102
- window.natively.trigger(undefined, 30, undefined, "app_console");
103
-
101
+ window.natively.trigger(undefined, 22, undefined, "app_console");
104
102
  },
105
103
 
106
104
  closeApp: function () {
@@ -144,35 +142,60 @@ window.natively = {
144
142
  window.natively.trigger(undefined, 18, undefined, "open_link", params);
145
143
  },
146
144
 
147
- openExternalAppIOS(url) {
145
+ openExternalAppIOS(url) { // DEPRECATED after 2.14.0
148
146
  window.natively.trigger(undefined, 0, undefined, "open_app", {
149
147
  url,
150
148
  });
151
149
  },
152
150
 
151
+ openExternalApp(url) {
152
+ window.natively.trigger(undefined, 22, undefined, "open_app", {
153
+ url,
154
+ });
155
+ },
156
+
153
157
  openAppSettings() {
154
158
  window.natively.trigger(undefined, 0, undefined, "open_appsettings");
155
159
  },
156
160
 
157
- hapticPatternIOS(pattern, delay) {
161
+ hapticPatternIOS(pattern, delay) { // DEPRECATED after 2.14.0
158
162
  window.natively.trigger(undefined, 7, undefined, "haptic_pattern", {
159
163
  pattern,
160
164
  delay
161
165
  });
162
166
  },
163
167
 
164
- hapticImpactIOS(type) {
168
+ hapticImpactIOS(type) { // DEPRECATED after 2.14.0
165
169
  window.natively.trigger(undefined, 7, undefined, "haptic_impact", {
166
170
  type,
167
171
  });
168
172
  },
169
173
 
170
- hapticNotificationIOS(type) {
174
+ hapticNotificationIOS(type) { // DEPRECATED after 2.14.0
171
175
  window.natively.trigger(undefined, 7, undefined, "haptic_notification", {
172
176
  type,
173
177
  });
174
178
  },
175
179
 
180
+ hapticPattern(pattern, delay) {
181
+ window.natively.trigger(undefined, 22, undefined, "haptic_pattern", {
182
+ pattern,
183
+ delay
184
+ });
185
+ },
186
+
187
+ hapticImpact(type) {
188
+ window.natively.trigger(undefined, 22, undefined, "haptic_impact", {
189
+ type,
190
+ });
191
+ },
192
+
193
+ hapticNotification(type) {
194
+ window.natively.trigger(undefined, 22, undefined, "haptic_notification", {
195
+ type,
196
+ });
197
+ },
198
+
176
199
  showAppToast(type, text) {
177
200
  const params = {};
178
201
  params.text = typeof text === "undefined" ? "" : text;
@@ -202,11 +225,16 @@ window.natively = {
202
225
  window.natively.trigger(undefined, 1, undefined, "app_progress", params);
203
226
  },
204
227
 
205
- setAppSwipeNavigationIOS(toggle) {
228
+ setAppSwipeNavigationIOS(toggle) { // DEPRECATED after 2.14.0
206
229
  const params = { toggle };
207
230
  window.natively.trigger(undefined, 1, undefined, "app_navigation", params);
208
231
  },
209
232
 
233
+ setAppSwipeNavigation(toggle) {
234
+ const params = { toggle };
235
+ window.natively.trigger(undefined, 22, undefined, "app_navigation", params);
236
+ },
237
+
210
238
  setAppPullToRefresh(toggle) {
211
239
  const params = { toggle };
212
240
  window.natively.trigger(undefined, 1, undefined, "app_pull", params);
@@ -217,7 +245,7 @@ window.natively = {
217
245
  window.natively.trigger(undefined, 3, undefined, "app_orientation", params);
218
246
  },
219
247
 
220
- setAppStatusBarStyleIOS(style) {
248
+ setAppStatusBarStyleIOS(style) { // DEPRECATED after 2.14.0
221
249
  const params = { style };
222
250
  window.natively.trigger(
223
251
  undefined,
@@ -228,6 +256,17 @@ window.natively = {
228
256
  );
229
257
  },
230
258
 
259
+ setAppStatusBarStyle(style) {
260
+ const params = { style };
261
+ window.natively.trigger(
262
+ undefined,
263
+ 22,
264
+ undefined,
265
+ "status_bar_style",
266
+ params
267
+ );
268
+ },
269
+
231
270
  hideLoadingScreen() {
232
271
  const show_loader = false;
233
272
  const auto_hide = true;
@@ -790,14 +829,7 @@ class NativelyAudioRecorder {
790
829
  // Make sure to use this an not reload page a lot
791
830
  class NativelyAdmobBanner {
792
831
  constructor(
793
- config = {
794
- iOSUnitId: "ca-app-pub-3940256099942544/2934735716",
795
- androidUnitId: "ca-app-pub-3940256099942544/6300978111",
796
- position: "BOTTOM",
797
- sizeType: "AUTO",
798
- custom_width: 320,
799
- custom_height: 50
800
- },
832
+ config,
801
833
  setup_callback = undefined, // function(resp) { console.log(resp) }
802
834
  preload_ad = false, // Load ad on init
803
835
  preload_callback = undefined, // function(resp) { console.log(resp) }
@@ -805,7 +837,7 @@ class NativelyAdmobBanner {
805
837
  show_callback = undefined, // function(resp) { console.log(resp) }
806
838
  ) {
807
839
  const id = generateID();
808
- const params = {};
840
+ let params = {};
809
841
  if (window.natively.isAndroidApp) {
810
842
  params.unitId = (typeof config.androidUnitId === "undefined") ? "ca-app-pub-3940256099942544/6300978111" : config.androidUnitId;
811
843
  } else if (window.natively.isIOSApp) {
@@ -814,8 +846,8 @@ class NativelyAdmobBanner {
814
846
 
815
847
  params.position = (typeof config.position === "undefined") ? "BOTTOM" : config.position;
816
848
  params.sizeType = (typeof config.sizeType === "undefined") ? "AUTO" : config.sizeType;
817
- params.width = (typeof config.custom_width === "undefined") ? 320 : config.width;
818
- params.height = (typeof config.custom_height === "undefined") ? 50 : config.height;
849
+ params.width = (typeof config.custom_width === "undefined") ? 320 : config.custom_width;
850
+ params.height = (typeof config.custom_height === "undefined") ? 50 : config.custom_height;
819
851
  window.natively.trigger(id, 14, function (resp) {
820
852
  if (typeof setup_callback !== "undefined") {
821
853
  setup_callback(resp);
@@ -1 +1 @@
1
- window.natively={isDebug:false,min_app_version:0,app_version:0,injected:false,observers:[],isIOSApp:window.navigator.userAgent.includes("Natively/iOS"),isAndroidApp:window.navigator.userAgent.includes("Natively/Android"),setDebug:function(isDebug){window.natively.isDebug=isDebug},notify:function(min,current){window.natively.injected=true;if(min){window.natively.min_app_version=min}if(current){window.natively.app_version=current}const observers=window.natively.observers;if(natively.isDebug){console.log("[INFO] Notify observers: ",observers.length)}while(observers.length>0){const observer=observers.shift();observer()}},addObserver:function(fn){if(window.natively.injected){fn()}else{if(window.natively.isDebug){console.log(`[DEBUG] addObserver: ${fn}`)}window.natively.observers.push(fn)}},trigger:function(respId,minVersion,callback,method,body){const isTestVersion=window.natively.isDebug;if(!window.natively.injected){window.natively.addObserver((()=>{window.natively.trigger(respId,minVersion,callback,method,body)}));return}if(minVersion>window.natively.app_version){if(isTestVersion){alert(`[ERROR] Please rebuild the app to use this functionality. App Version: ${window.natively.app_version}, feature version: ${minVersion}`)}return}if(callback){let fullMethodName;if(respId){fullMethodName=method+"_response"+"_"+respId}else{fullMethodName=method+"_response"}window[fullMethodName]=function(resp,err){$agent.response();if(err.message&&isTestVersion){alert(`[ERROR] Error message: ${err.message}`);return}if(isTestVersion){console.log(`[DEBUG] Callback method: ${fullMethodName}, body: ${JSON.stringify(resp)}, respId: ${respId}`)}callback(resp)};if(body){body.response_id=respId}else{body={response_id:respId}}}if(isTestVersion){console.log(`[DEBUG] Trigger method: ${method}, body: ${JSON.stringify(body)}`)}$agent.trigger(method,body)},openLogger:function(){$agent.natively_logger()},openConsole:function(){window.natively.trigger(undefined,30,undefined,"app_console")},closeApp:function(){window.natively.trigger(undefined,11,undefined,"app_close")},showProgress:function(toggle){window.natively.trigger(undefined,11,undefined,"app_show_progress",{toggle:toggle})},shareImage(image_url){window.natively.trigger(undefined,0,undefined,"share_image",{url:image_url})},shareText(text){window.natively.trigger(undefined,0,undefined,"share_text",{text:text})},shareTextAndImage(text,image_url){window.natively.trigger(undefined,0,undefined,"share_text_and_image",{url:image_url,text:text})},shareFile(file_url){window.natively.trigger(undefined,2,undefined,"share_file",{url:file_url})},openExternalURL(url,external){const params={};params.url=typeof url==="undefined"?"https://buildnatively.com":url;const isExternal=typeof external==="undefined"?false:external;params.view=isExternal?"external":"web";window.natively.trigger(undefined,18,undefined,"open_link",params)},openExternalAppIOS(url){window.natively.trigger(undefined,0,undefined,"open_app",{url:url})},openAppSettings(){window.natively.trigger(undefined,0,undefined,"open_appsettings")},hapticPatternIOS(pattern,delay){window.natively.trigger(undefined,7,undefined,"haptic_pattern",{pattern:pattern,delay:delay})},hapticImpactIOS(type){window.natively.trigger(undefined,7,undefined,"haptic_impact",{type:type})},hapticNotificationIOS(type){window.natively.trigger(undefined,7,undefined,"haptic_notification",{type:type})},showAppToast(type,text){const params={};params.text=typeof text==="undefined"?"":text;params.type=typeof type==="undefined"?"DEFAULT":type;window.natively.trigger(undefined,0,undefined,"show_toast",params)},showAppBanner(type,title,description){const params={};params.type=typeof type==="undefined"?"INFO":type;params.title=typeof title==="undefined"?"":title;params.description=typeof description==="undefined"?"":description;window.natively.trigger(undefined,0,undefined,"show_banner",params)},requestAppReview(){window.natively.trigger(undefined,0,undefined,"request_review")},setAppBackgroundColor(color){const params={color:color};window.natively.trigger(undefined,1,undefined,"app_background",params)},setAppProgressColor(color){const params={color:color};window.natively.trigger(undefined,1,undefined,"app_progress",params)},setAppSwipeNavigationIOS(toggle){const params={toggle:toggle};window.natively.trigger(undefined,1,undefined,"app_navigation",params)},setAppPullToRefresh(toggle){const params={toggle:toggle};window.natively.trigger(undefined,1,undefined,"app_pull",params)},setAppOrientation(orientation){const params={orientation:orientation};window.natively.trigger(undefined,3,undefined,"app_orientation",params)},setAppStatusBarStyleIOS(style){const params={style:style};window.natively.trigger(undefined,2,undefined,"status_bar_style",params)},hideLoadingScreen(){const show_loader=false;const auto_hide=true;const params={show_loader:show_loader,auto_hide:auto_hide};window.natively.trigger(undefined,17,undefined,"loading_screen",params)},showLoadingScreen(autoHide){const show_loader=true;const auto_hide=typeof autoHide==="undefined"?false:autoHide;const params={show_loader:show_loader,auto_hide:auto_hide};window.natively.trigger(undefined,17,undefined,"loading_screen",params)},async sendPushNotification(appId,payload,player_ids,isPreview){const filtered=player_ids.filter((id=>id.length>0));const include_player_ids=[...new Set(filtered)];let notification={app_id:isPreview?"be83022a-1d08-45d0-a07a-0c3655666e17":appId,include_player_ids:include_player_ids};if(payload.template_id){notification.template_id=payload.template_id}else{notification.headings={};notification.headings.en=payload.title||"Empty Title";notification.contents={};notification.contents.en=payload.message||"Empty Message";if(payload.subtitle){notification.subtitle={};notification.subtitle.en=payload.subtitle}if(payload.redirect_url){notification.url=payload.redirect_url}}const options={method:"POST",headers:{"Content-type":"application/json"},body:JSON.stringify(notification)};return await fetch("https://onesignal.com/api/v1/notifications",options)}};window.natively.addObserver((()=>window.natively.trigger(undefined,0,(resp=>{window.natively.min_app_version=resp.minSDKVersion;window.natively.app_version=resp.sdkVersion}),"app_info",{})));class NativelyInfo{constructor(){const id=generateID();this.browserInfo=function(){const isNativeApp=typeof $agent!=="undefined";const isIOSApp=window.navigator.userAgent.includes("Natively/iOS");const isAndroidApp=window.navigator.userAgent.includes("Natively/Android");return{isNativeApp:isNativeApp,isIOSApp:isIOSApp,isAndroidApp:isAndroidApp}};this.getAppInfo=function(app_info_callback){window.natively.trigger(id,0,app_info_callback,"app_info")};this.connectivity=function(connectivity_callback){window.natively.trigger(undefined,0,connectivity_callback,"connectivity")};this.app_state=function(app_state_callback){window.natively.trigger(undefined,19,app_state_callback,"app_state")}}}class NativelyClipboard{constructor(){const id=generateID();this.copy=function(text){window.natively.trigger(undefined,11,undefined,"clipboard_copy",{text:text})};this.paste=function(paste_callback){window.natively.trigger(id,11,paste_callback,"clipboard_paste")}}}class NativelyPagesCache{constructor(){const id=generateID();this.currentPageCached=function(current_page_cached_callback){window.natively.trigger(id,4,current_page_cached_callback,"current_page_cached")};this.storeCurrentPage=function(store_current_page_callback){window.natively.trigger(id,4,store_current_page_callback,"store_current_page")};this.resetCurrentPage=function(reset_current_page_callback){window.natively.trigger(id,4,reset_current_page_callback,"reset_current_page")};this.resetAll=function(reset_all_callback){window.natively.trigger(id,4,reset_all_callback,"reset_all")}}}class NativelyNotifications{constructor(){const id=generateID();this.getOneSignalId=function(onesignal_playerid_callback){window.natively.trigger(id,0,onesignal_playerid_callback,"onesignal_playerid")};this.requestPermission=function(fallbackToSettings,push_register_callback){window.natively.trigger(id,0,push_register_callback,"push_register",{fallbackToSettings:fallbackToSettings})};this.getPermissionStatus=function(push_permission_callback){window.natively.trigger(id,0,push_permission_callback,"push_permission")}}}class NativelyGeolocation{constructor(){const id=generateID();this.getUserGeolocation=function(distance,geolocation_callback){window.natively.trigger(id,0,geolocation_callback,"geolocation",{distance:distance})};this.requestPermission=function(geo_register_callback){window.natively.trigger(id,0,geo_register_callback,"geo_register")};this.getPermissionStatus=function(geo_permission_callback){window.natively.trigger(id,0,geo_permission_callback,"geo_permission")}}}class NativelyLocation{constructor(){const id=generateID();this.current=function(minAccuracyIOS,accuracyTypeIOS,priority_android,location_callback){window.natively.trigger(id,12,location_callback,"location_current",{minAccuracy:minAccuracyIOS,accuracyType:accuracyTypeIOS,priority:priority_android})};this.permission=function(location_permission_callback){window.natively.trigger(id,6,location_permission_callback,"location_permission")};this.start=function(interval,minAccuracyIOS,accuracyTypeIOS,priority_android,location_callback){window.natively.trigger(id,12,location_callback,"location_start",{minAccuracy:minAccuracyIOS,accuracyType:accuracyTypeIOS,priority:priority_android,interval:interval})};this.stop=function(){window.natively.trigger(id,3,undefined,"location_stop",{})};this.startBackground=function(interval,minAccuracyIOS,accuracyTypeIOS,priority_android,responseIdentifier,location_bg_callback){const params={};params.identifier=typeof responseIdentifier==="undefined"?"empty":responseIdentifier;params.interval=typeof interval==="undefined"?1e3*60:interval;params.minAccuracy=typeof minAccuracyIOS==="undefined"?50:minAccuracyIOS;params.accuracyType=typeof accuracyTypeIOS==="undefined"?"Best":accuracyTypeIOS;params.priority=typeof priority_android==="undefined"?"BALANCED":priority_android;window.natively.trigger(id,12,location_bg_callback,"location_start_bg",params)};this.statusBackground=function(location_bg_status_callback){window.natively.trigger(id,20,location_bg_status_callback,"location_status_bg",{})};this.stopBackground=function(location_bg_callback){window.natively.trigger(id,4,location_bg_callback,"location_stop_bg",{})}}}class NativelyMessage{constructor(){const id=generateID();this.sendSMS=function(body,recipient,send_sms_callback){const params={};params.body=typeof body==="undefined"?"":body;params.recipient=typeof recipient==="undefined"?"":recipient;window.natively.trigger(id,0,send_sms_callback,"send_sms",params)};this.sendEmail=function(subject,body,recipient,send_email_callback){const params={};params.subject=typeof subject==="undefined"?"":subject;params.body=typeof body==="undefined"?"":body;params.recipient=typeof recipient==="undefined"?"":recipient;window.natively.trigger(id,0,send_email_callback,"send_email",params)}}}class NativelyStorage{constructor(){const id=generateID();this.setStorageValue=function(key,value){window.natively.trigger(id,0,undefined,"set_storage_value",{key:key,value:value})};this.getStorageValue=function(key,get_storage_value_callback){window.natively.trigger(id,0,get_storage_value_callback,"get_storage_value",{key:key})};this.removeStorageValue=function(key){window.natively.trigger(id,0,undefined,"remove_storage_value",{key:key})};this.resetStorage=function(){window.natively.trigger(id,0,undefined,"reset_storage")}}}class NativelyBiometrics{constructor(allowPass){this.allowPass=allowPass;const id=generateID();this.checkBiometricsSupport=function(biometrics_support_callback){window.natively.trigger(id,0,biometrics_support_callback,"biometrics_support",{allowPass:allowPass})};this.checkCredentials=function(biometrics_has_credentials_callback){window.natively.trigger(id,0,biometrics_has_credentials_callback,"biometrics_has_credentials")};this.verifyUserIdentify=function(biometrics_verify_callback){window.natively.trigger(id,0,biometrics_verify_callback,"biometrics_verify",{allowPass:allowPass})};this.getUserCredentials=function(biometrics_auth_callback){window.natively.trigger(id,0,biometrics_auth_callback,"biometrics_auth",{allowPass:allowPass})};this.removeUserCredentials=function(biometrics_remove_credentials_callback){window.natively.trigger(id,0,biometrics_remove_credentials_callback,"biometrics_remove_credentials")};this.saveUserCredentials=function(login,password,biometrics_auth_callback){window.natively.trigger(id,0,biometrics_auth_callback,"biometrics_auth",{allowPass:allowPass,login:login,password:password})}}}class NativelyDatePicker{constructor(){const id=generateID();this.showDatePicker=function(title,description,type,style,datepicker_callback){let params={};params.type=typeof type==="undefined"?"DATE":type;params.style=typeof style==="undefined"?"LIGHT":style;params.title=typeof title==="undefined"?"":title;params.description=typeof description==="undefined"?"":description;window.natively.trigger(id,0,datepicker_callback,"datepicker",params)}}}class NativelyCamera{constructor(){const id=generateID();this.showCamera=function(type,quality,camera,open_camera_callback){let params={};params.type=typeof type==="undefined"?"photo":type;params.quality=typeof quality==="undefined"?"high":quality;params.camera=typeof camera==="undefined"?"BACK":camera;window.natively.trigger(id,2,open_camera_callback,"open_camera",params)}}}class NativelyHealth{constructor(){const id=generateID();this.available=function(available_callback){window.natively.trigger(id,10,available_callback,"health_available",{})};this.requestAuthorization=function(write_data_types,read_data_types,request_callback){window.natively.trigger(id,10,request_callback,"health_register",{write_data_types:write_data_types,read_data_types:read_data_types})};this.permissionStatus=function(data_type,callback){window.natively.trigger(id,10,callback,"health_permission",{data_type:data_type})};this.getAllCharacteristics=function(callback){window.natively.trigger(id,10,callback,"health_get_all_characteristics",{})};this.getStatisticQuantity=function(data_type,interval,start_date,end_date,callback){const obj={data_type:data_type,interval:interval};if(typeof start_date!=="undefined"){obj.start_date=start_date.getTime()}if(typeof end_date!=="undefined"){obj.end_date=end_date.getTime()}window.natively.trigger(id,10,callback,"health_get_statistic_quantity",obj)};this.getDailySleepAnalysis=function(start_date,end_date,limit,callback){const obj={limit:limit||100};if(typeof start_date!=="undefined"){obj.start_date=start_date.getTime()}if(typeof end_date!=="undefined"){obj.end_date=end_date.getTime()}window.natively.trigger(id,10,callback,"health_get_daily_sleep_analysis",obj)};this.getWorkouts=function(start_date,end_date,limit,callback){const obj={limit:limit||100};if(typeof start_date!=="undefined"){obj.start_date=start_date.getTime()}if(typeof end_date!=="undefined"){obj.end_date=end_date.getTime()}window.natively.trigger(id,21,callback,"health_get_workouts",obj)};this.getActivitySummary=function(start_date,end_date,callback){const obj={};if(typeof start_date!=="undefined"){obj.start_date=start_date.getTime()}if(typeof end_date!=="undefined"){obj.end_date=end_date.getTime()}window.natively.trigger(id,10,callback,"health_get_activity_summary",obj)}}}class NativelyScanner{constructor(){const id=generateID();this.showScanner=function(open_scanner_callback){window.natively.trigger(id,2,open_scanner_callback,"open_scanner",{})}}}class NativelyPurchases{constructor(){const id=generateID();this.login=function(login,customerEmail,login_callback){const email=typeof customerEmail==="undefined"?"":customerEmail;window.natively.trigger(id,3,login_callback,"purchases_login",{login:login,email:email})};this.logout=function(logout_callback){window.natively.trigger(id,3,logout_callback,"purchases_logout",{})};this.customerId=function(customer_id_callback){window.natively.trigger(id,3,customer_id_callback,"purchases_customerid",{})};this.restore=function(restore_callback){window.natively.trigger(id,10,restore_callback,"purchases_restore",{})};this.purchasePackage=function(packageId,purchase_callback){window.natively.trigger(id,3,purchase_callback,"purchases_package",{packageId:packageId})};this.packagePrice=function(packageId,purchase_callback){window.natively.trigger(id,8,purchase_callback,"purchases_price",{packageId:packageId})}}}class NativelyContacts{constructor(){const id=generateID();this.getAllContacts=function(contacts_all_callback){window.natively.trigger(id,3,contacts_all_callback,"contacts_all",{})};this.createContact=function(firstName,lastName,email,phone,contacts_save_callback){let params={firstName:firstName};params.lastName=typeof lastName==="undefined"?"":lastName;params.email=typeof email==="undefined"?"":email;params.phone=typeof phone==="undefined"?"":phone;window.natively.trigger(id,3,contacts_save_callback,"contacts_save",params)}}}class NativelyMediaPicker{constructor(){const id=generateID();this.showMediaPicker=function(mediapicker_callback){window.natively.trigger(id,8,mediapicker_callback,"mediapicker",{})}}}class NativelyAudioRecorder{constructor(){const id=generateID();this.showRecorder=function(max_duration,record_callback){let params={};params.max_duration=typeof max_duration==="undefined"?0:max_duration;window.natively.trigger(id,13,record_callback,"record_start",params)}}}class NativelyAdmobBanner{constructor(config={iOSUnitId:"ca-app-pub-3940256099942544/2934735716",androidUnitId:"ca-app-pub-3940256099942544/6300978111",position:"BOTTOM",sizeType:"AUTO",custom_width:320,custom_height:50},setup_callback=undefined,preload_ad=false,preload_callback=undefined,show_ad=false,show_callback=undefined){const id=generateID();const params={};if(window.natively.isAndroidApp){params.unitId=typeof config.androidUnitId==="undefined"?"ca-app-pub-3940256099942544/6300978111":config.androidUnitId}else if(window.natively.isIOSApp){params.unitId=typeof config.iOSUnitId==="undefined"?"ca-app-pub-3940256099942544/2934735716":config.iOSUnitId}params.position=typeof config.position==="undefined"?"BOTTOM":config.position;params.sizeType=typeof config.sizeType==="undefined"?"AUTO":config.sizeType;params.width=typeof config.custom_width==="undefined"?320:config.width;params.height=typeof config.custom_height==="undefined"?50:config.height;window.natively.trigger(id,14,(function(resp){if(typeof setup_callback!=="undefined"){setup_callback(resp)}if(preload_ad){window.natively.trigger(id,14,(function(resp){if(typeof preload_callback!=="undefined"){preload_callback(resp)}if(show_ad){window.natively.trigger(id,14,show_callback,"bannerad_show",{})}}),"bannerad_load",{})}}),"bannerad_setup",params);this.loadAd=function(callback){window.natively.trigger(id,14,callback,"bannerad_load",{})};this.showBanner=function(callback){window.natively.trigger(id,14,callback,"bannerad_show",{})};this.hideBanner=function(callback){window.natively.trigger(id,14,callback,"bannerad_hide",{})};this.bannerIsReady=function(callback){window.natively.trigger(id,14,callback,"bannerad_ready",{})};this.bannerIsVisible=function(callback){window.natively.trigger(id,14,callback,"bannerad_visible",{})}}}class NativelyAdmobInterstitial{constructor(iOSUnitId="ca-app-pub-3940256099942544/4411468910",androidUnitId="ca-app-pub-3940256099942544/1033173712",setup_callback=undefined,auto_ad_reload=false,auto_ad_reload_callback=undefined){const id=generateID();let unitId;if(window.natively.isAndroidApp){unitId=typeof androidUnitId==="undefined"?"ca-app-pub-3940256099942544/1033173712":androidUnitId}else if(window.natively.isIOSApp){unitId=typeof iOSUnitId==="undefined"?"ca-app-pub-3940256099942544/4411468910":iOSUnitId}this.loadAd=function(callback){const params={};params.unitId=typeof unitId==="undefined"?"ca-app-pub-3940256099942544/4411468910":unitId;window.natively.trigger(id,14,callback,"interstitialad_setup",params)};this.showInterstitialAd=function(callback){window.natively.trigger(id,14,(function(resp){callback(resp);if(resp.event==="DID_DISMISS_AD"&&auto_ad_reload){const params={};params.unitId=unitId;setTimeout((()=>{window.natively.trigger(id,14,auto_ad_reload_callback,"interstitialad_setup",params)}),500)}}),"interstitialad_show",{})};this.interstitialIsReady=function(callback){window.natively.trigger(id,14,callback,"interstitialad_ready",{})};this.loadAd(setup_callback)}}class NativelyNFCService{constructor(readAlertMessage,writeAlertMessage,readDetectedMessage,writeDetectedMessage){const id=generateID();this.readAlertMessage=readAlertMessage;this.writeAlertMessage=writeAlertMessage;this.readDetectedMessage=readDetectedMessage;this.writeDetectedMessage=writeDetectedMessage;this.read=function(callback){let params={};params.alertMessage=typeof this.readAlertMessage==="undefined"?"please set readAlertMessage":this.readAlertMessage;params.detectedMessage=typeof this.readDetectedMessage==="undefined"?"readDetectedMessage":this.readDetectedMessage;window.natively.trigger(id,15,callback,"nfc_read",params)};this.write=function(recordId,recordData,callback){let params={};params.alertMessage=typeof this.writeAlertMessage==="undefined"?"please set writeAlertMessage":this.writeAlertMessage;params.detectedMessage=typeof this.writeDetectedMessage==="undefined"?"please set writeDetectedMessage":this.writeDetectedMessage;params.recordData=typeof recordData==="undefined"?"please set recordData":recordData;params.recordId=typeof recordId==="undefined"?"please set recordId":recordId;window.natively.trigger(id,15,callback,"nfc_write",params)};this.available=function(callback){let params={};window.natively.trigger(id,15,callback,"nfc_available",params)}}}class NativelyAppleSignInService{constructor(){const id=generateID();this.signin=function(callback){let params={};window.natively.trigger(id,16,callback,"apple_signin",params)}}}function generateID(){return Date.now().toString(36)+Math.random().toString(36).substring(2)}
1
+ window.natively = { isDebug: !1, min_app_version: 0, app_version: 0, injected: !1, observers: [], isIOSApp: window.navigator.userAgent.includes("Natively/iOS"), isAndroidApp: window.navigator.userAgent.includes("Natively/Android"), setDebug: function (i) { window.natively.isDebug = i }, notify: function (i, t) { window.natively.injected = !0, i && (window.natively.min_app_version = i), t && (window.natively.app_version = t); const e = window.natively.observers; for (natively.isDebug; e.length > 0;) { e.shift()() } }, addObserver: function (i) { window.natively.injected ? i() : (window.natively.isDebug, window.natively.observers.push(i)) }, trigger: function (i, t, e, n, o) { const a = window.natively.isDebug; if (window.natively.injected) if (t > window.natively.app_version) a && alert(`[ERROR] Please rebuild the app to use this functionality. App Version: ${window.natively.app_version}, feature version: ${t}`); else { if (e) { let t; t = i ? n + "_response_" + i : n + "_response", window[t] = function (i, t) { $agent.response(), t.message && a ? alert(`[ERROR] Error message: ${t.message}`) : e(i) }, o ? o.response_id = i : o = { response_id: i } } $agent.trigger(n, o) } else window.natively.addObserver((() => { window.natively.trigger(i, t, e, n, o) })) }, openLogger: function () { $agent.natively_logger() }, openConsole: function () { window.natively.trigger(void 0, 22, void 0, "app_console") }, closeApp: function () { window.natively.trigger(void 0, 11, void 0, "app_close") }, showProgress: function (i) { window.natively.trigger(void 0, 11, void 0, "app_show_progress", { toggle: i }) }, shareImage(i) { window.natively.trigger(void 0, 0, void 0, "share_image", { url: i }) }, shareText(i) { window.natively.trigger(void 0, 0, void 0, "share_text", { text: i }) }, shareTextAndImage(i, t) { window.natively.trigger(void 0, 0, void 0, "share_text_and_image", { url: t, text: i }) }, shareFile(i) { window.natively.trigger(void 0, 2, void 0, "share_file", { url: i }) }, openExternalURL(i, t) { const e = {}; e.url = void 0 === i ? "https://buildnatively.com" : i; const n = void 0 !== t && t; e.view = n ? "external" : "web", window.natively.trigger(void 0, 18, void 0, "open_link", e) }, openExternalAppIOS(i) { window.natively.trigger(void 0, 0, void 0, "open_app", { url: i }) }, openExternalApp(i) { window.natively.trigger(void 0, 22, void 0, "open_app", { url: i }) }, openAppSettings() { window.natively.trigger(void 0, 0, void 0, "open_appsettings") }, hapticPatternIOS(i, t) { window.natively.trigger(void 0, 7, void 0, "haptic_pattern", { pattern: i, delay: t }) }, hapticImpactIOS(i) { window.natively.trigger(void 0, 7, void 0, "haptic_impact", { type: i }) }, hapticNotificationIOS(i) { window.natively.trigger(void 0, 7, void 0, "haptic_notification", { type: i }) }, hapticPattern(i, t) { window.natively.trigger(void 0, 22, void 0, "haptic_pattern", { pattern: i, delay: t }) }, hapticImpact(i) { window.natively.trigger(void 0, 22, void 0, "haptic_impact", { type: i }) }, hapticNotification(i) { window.natively.trigger(void 0, 22, void 0, "haptic_notification", { type: i }) }, showAppToast(i, t) { const e = {}; e.text = void 0 === t ? "" : t, e.type = void 0 === i ? "DEFAULT" : i, window.natively.trigger(void 0, 0, void 0, "show_toast", e) }, showAppBanner(i, t, e) { const n = {}; n.type = void 0 === i ? "INFO" : i, n.title = void 0 === t ? "" : t, n.description = void 0 === e ? "" : e, window.natively.trigger(void 0, 0, void 0, "show_banner", n) }, requestAppReview() { window.natively.trigger(void 0, 0, void 0, "request_review") }, setAppBackgroundColor(i) { const t = { color: i }; window.natively.trigger(void 0, 1, void 0, "app_background", t) }, setAppProgressColor(i) { const t = { color: i }; window.natively.trigger(void 0, 1, void 0, "app_progress", t) }, setAppSwipeNavigationIOS(i) { const t = { toggle: i }; window.natively.trigger(void 0, 1, void 0, "app_navigation", t) }, setAppSwipeNavigation(i) { const t = { toggle: i }; window.natively.trigger(void 0, 1, void 0, "app_navigation", t) }, setAppPullToRefresh(i) { const t = { toggle: i }; window.natively.trigger(void 0, 1, void 0, "app_pull", t) }, setAppOrientation(i) { const t = { orientation: i }; window.natively.trigger(void 0, 3, void 0, "app_orientation", t) }, setAppStatusBarStyleIOS(i) { const t = { style: i }; window.natively.trigger(void 0, 2, void 0, "status_bar_style", t) }, setAppStatusBarStyle(i) { const t = { style: i }; window.natively.trigger(void 0, 22, void 0, "status_bar_style", t) }, hideLoadingScreen() { const i = { show_loader: !1, auto_hide: !0 }; window.natively.trigger(void 0, 17, void 0, "loading_screen", i) }, showLoadingScreen(i) { const t = { show_loader: !0, auto_hide: void 0 !== i && i }; window.natively.trigger(void 0, 17, void 0, "loading_screen", t) }, async sendPushNotification(i, t, e, n) { const o = e.filter((i => i.length > 0)); let a = { app_id: n ? "be83022a-1d08-45d0-a07a-0c3655666e17" : i, include_player_ids: [...new Set(o)] }; t.template_id ? a.template_id = t.template_id : (a.headings = {}, a.headings.en = t.title || "Empty Title", a.contents = {}, a.contents.en = t.message || "Empty Message", t.subtitle && (a.subtitle = {}, a.subtitle.en = t.subtitle), t.redirect_url && (a.url = t.redirect_url)); const r = { method: "POST", headers: { "Content-type": "application/json" }, body: JSON.stringify(a) }; return await fetch("https://onesignal.com/api/v1/notifications", r) } }, window.natively.addObserver((() => window.natively.trigger(void 0, 0, (i => { window.natively.min_app_version = i.minSDKVersion, window.natively.app_version = i.sdkVersion }), "app_info", {}))); class NativelyInfo { constructor() { const i = generateID(); this.browserInfo = function () { return { isNativeApp: "undefined" != typeof $agent, isIOSApp: window.navigator.userAgent.includes("Natively/iOS"), isAndroidApp: window.navigator.userAgent.includes("Natively/Android") } }, this.getAppInfo = function (t) { window.natively.trigger(i, 0, t, "app_info") }, this.connectivity = function (i) { window.natively.trigger(void 0, 0, i, "connectivity") }, this.app_state = function (i) { window.natively.trigger(void 0, 19, i, "app_state") } } } class NativelyClipboard { constructor() { const i = generateID(); this.copy = function (i) { window.natively.trigger(void 0, 11, void 0, "clipboard_copy", { text: i }) }, this.paste = function (t) { window.natively.trigger(i, 11, t, "clipboard_paste") } } } class NativelyPagesCache { constructor() { const i = generateID(); this.currentPageCached = function (t) { window.natively.trigger(i, 4, t, "current_page_cached") }, this.storeCurrentPage = function (t) { window.natively.trigger(i, 4, t, "store_current_page") }, this.resetCurrentPage = function (t) { window.natively.trigger(i, 4, t, "reset_current_page") }, this.resetAll = function (t) { window.natively.trigger(i, 4, t, "reset_all") } } } class NativelyNotifications { constructor() { const i = generateID(); this.getOneSignalId = function (t) { window.natively.trigger(i, 0, t, "onesignal_playerid") }, this.requestPermission = function (t, e) { window.natively.trigger(i, 0, e, "push_register", { fallbackToSettings: t }) }, this.getPermissionStatus = function (t) { window.natively.trigger(i, 0, t, "push_permission") } } } class NativelyGeolocation { constructor() { const i = generateID(); this.getUserGeolocation = function (t, e) { window.natively.trigger(i, 0, e, "geolocation", { distance: t }) }, this.requestPermission = function (t) { window.natively.trigger(i, 0, t, "geo_register") }, this.getPermissionStatus = function (t) { window.natively.trigger(i, 0, t, "geo_permission") } } } class NativelyLocation { constructor() { const i = generateID(); this.current = function (t, e, n, o) { window.natively.trigger(i, 12, o, "location_current", { minAccuracy: t, accuracyType: e, priority: n }) }, this.permission = function (t) { window.natively.trigger(i, 6, t, "location_permission") }, this.start = function (t, e, n, o, a) { window.natively.trigger(i, 12, a, "location_start", { minAccuracy: e, accuracyType: n, priority: o, interval: t }) }, this.stop = function () { window.natively.trigger(i, 3, void 0, "location_stop", {}) }, this.startBackground = function (t, e, n, o, a, r) { const s = {}; s.identifier = void 0 === a ? "empty" : a, s.interval = void 0 === t ? 6e4 : t, s.minAccuracy = void 0 === e ? 50 : e, s.accuracyType = void 0 === n ? "Best" : n, s.priority = void 0 === o ? "BALANCED" : o, window.natively.trigger(i, 12, r, "location_start_bg", s) }, this.statusBackground = function (t) { window.natively.trigger(i, 20, t, "location_status_bg", {}) }, this.stopBackground = function (t) { window.natively.trigger(i, 4, t, "location_stop_bg", {}) } } } class NativelyMessage { constructor() { const i = generateID(); this.sendSMS = function (t, e, n) { const o = {}; o.body = void 0 === t ? "" : t, o.recipient = void 0 === e ? "" : e, window.natively.trigger(i, 0, n, "send_sms", o) }, this.sendEmail = function (t, e, n, o) { const a = {}; a.subject = void 0 === t ? "" : t, a.body = void 0 === e ? "" : e, a.recipient = void 0 === n ? "" : n, window.natively.trigger(i, 0, o, "send_email", a) } } } class NativelyStorage { constructor() { const i = generateID(); this.setStorageValue = function (t, e) { window.natively.trigger(i, 0, void 0, "set_storage_value", { key: t, value: e }) }, this.getStorageValue = function (t, e) { window.natively.trigger(i, 0, e, "get_storage_value", { key: t }) }, this.removeStorageValue = function (t) { window.natively.trigger(i, 0, void 0, "remove_storage_value", { key: t }) }, this.resetStorage = function () { window.natively.trigger(i, 0, void 0, "reset_storage") } } } class NativelyBiometrics { constructor(i) { this.allowPass = i; const t = generateID(); this.checkBiometricsSupport = function (e) { window.natively.trigger(t, 0, e, "biometrics_support", { allowPass: i }) }, this.checkCredentials = function (i) { window.natively.trigger(t, 0, i, "biometrics_has_credentials") }, this.verifyUserIdentify = function (e) { window.natively.trigger(t, 0, e, "biometrics_verify", { allowPass: i }) }, this.getUserCredentials = function (e) { window.natively.trigger(t, 0, e, "biometrics_auth", { allowPass: i }) }, this.removeUserCredentials = function (i) { window.natively.trigger(t, 0, i, "biometrics_remove_credentials") }, this.saveUserCredentials = function (e, n, o) { window.natively.trigger(t, 0, o, "biometrics_auth", { allowPass: i, login: e, password: n }) } } } class NativelyDatePicker { constructor() { const i = generateID(); this.showDatePicker = function (t, e, n, o, a) { let r = {}; r.type = void 0 === n ? "DATE" : n, r.style = void 0 === o ? "LIGHT" : o, r.title = void 0 === t ? "" : t, r.description = void 0 === e ? "" : e, window.natively.trigger(i, 0, a, "datepicker", r) } } } class NativelyCamera { constructor() { const i = generateID(); this.showCamera = function (t, e, n, o) { let a = {}; a.type = void 0 === t ? "photo" : t, a.quality = void 0 === e ? "high" : e, a.camera = void 0 === n ? "BACK" : n, window.natively.trigger(i, 2, o, "open_camera", a) } } } class NativelyHealth { constructor() { const i = generateID(); this.available = function (t) { window.natively.trigger(i, 10, t, "health_available", {}) }, this.requestAuthorization = function (t, e, n) { window.natively.trigger(i, 10, n, "health_register", { write_data_types: t, read_data_types: e }) }, this.permissionStatus = function (t, e) { window.natively.trigger(i, 10, e, "health_permission", { data_type: t }) }, this.getAllCharacteristics = function (t) { window.natively.trigger(i, 10, t, "health_get_all_characteristics", {}) }, this.getStatisticQuantity = function (t, e, n, o, a) { const r = { data_type: t, interval: e }; void 0 !== n && (r.start_date = n.getTime()), void 0 !== o && (r.end_date = o.getTime()), window.natively.trigger(i, 10, a, "health_get_statistic_quantity", r) }, this.getDailySleepAnalysis = function (t, e, n, o) { const a = { limit: n || 100 }; void 0 !== t && (a.start_date = t.getTime()), void 0 !== e && (a.end_date = e.getTime()), window.natively.trigger(i, 10, o, "health_get_daily_sleep_analysis", a) }, this.getWorkouts = function (t, e, n, o) { const a = { limit: n || 100 }; void 0 !== t && (a.start_date = t.getTime()), void 0 !== e && (a.end_date = e.getTime()), window.natively.trigger(i, 21, o, "health_get_workouts", a) }, this.getActivitySummary = function (t, e, n) { const o = {}; void 0 !== t && (o.start_date = t.getTime()), void 0 !== e && (o.end_date = e.getTime()), window.natively.trigger(i, 10, n, "health_get_activity_summary", o) } } } class NativelyScanner { constructor() { const i = generateID(); this.showScanner = function (t) { window.natively.trigger(i, 2, t, "open_scanner", {}) } } } class NativelyPurchases { constructor() { const i = generateID(); this.login = function (t, e, n) { const o = void 0 === e ? "" : e; window.natively.trigger(i, 3, n, "purchases_login", { login: t, email: o }) }, this.logout = function (t) { window.natively.trigger(i, 3, t, "purchases_logout", {}) }, this.customerId = function (t) { window.natively.trigger(i, 3, t, "purchases_customerid", {}) }, this.restore = function (t) { window.natively.trigger(i, 10, t, "purchases_restore", {}) }, this.purchasePackage = function (t, e) { window.natively.trigger(i, 3, e, "purchases_package", { packageId: t }) }, this.packagePrice = function (t, e) { window.natively.trigger(i, 8, e, "purchases_price", { packageId: t }) } } } class NativelyContacts { constructor() { const i = generateID(); this.getAllContacts = function (t) { window.natively.trigger(i, 3, t, "contacts_all", {}) }, this.createContact = function (t, e, n, o, a) { let r = { firstName: t }; r.lastName = void 0 === e ? "" : e, r.email = void 0 === n ? "" : n, r.phone = void 0 === o ? "" : o, window.natively.trigger(i, 3, a, "contacts_save", r) } } } class NativelyMediaPicker { constructor() { const i = generateID(); this.showMediaPicker = function (t) { window.natively.trigger(i, 8, t, "mediapicker", {}) } } } class NativelyAudioRecorder { constructor() { const i = generateID(); this.showRecorder = function (t, e) { let n = {}; n.max_duration = void 0 === t ? 0 : t, window.natively.trigger(i, 13, e, "record_start", n) } } } class NativelyAdmobBanner { constructor(i, t, e = !1, n, o = !1, a) { const r = generateID(); let s = {}; window.natively.isAndroidApp ? s.unitId = void 0 === i.androidUnitId ? "ca-app-pub-3940256099942544/6300978111" : i.androidUnitId : window.natively.isIOSApp && (s.unitId = void 0 === i.iOSUnitId ? "ca-app-pub-3940256099942544/2934735716" : i.iOSUnitId), s.position = void 0 === i.position ? "BOTTOM" : i.position, s.sizeType = void 0 === i.sizeType ? "AUTO" : i.sizeType, s.width = void 0 === i.custom_width ? 320 : i.custom_width, s.height = void 0 === i.custom_height ? 50 : i.custom_height, window.natively.trigger(r, 14, (function (i) { void 0 !== t && t(i), e && window.natively.trigger(r, 14, (function (i) { void 0 !== n && n(i), o && window.natively.trigger(r, 14, a, "bannerad_show", {}) }), "bannerad_load", {}) }), "bannerad_setup", s), this.loadAd = function (i) { window.natively.trigger(r, 14, i, "bannerad_load", {}) }, this.showBanner = function (i) { window.natively.trigger(r, 14, i, "bannerad_show", {}) }, this.hideBanner = function (i) { window.natively.trigger(r, 14, i, "bannerad_hide", {}) }, this.bannerIsReady = function (i) { window.natively.trigger(r, 14, i, "bannerad_ready", {}) }, this.bannerIsVisible = function (i) { window.natively.trigger(r, 14, i, "bannerad_visible", {}) } } } class NativelyAdmobInterstitial { constructor(i = "ca-app-pub-3940256099942544/4411468910", t = "ca-app-pub-3940256099942544/1033173712", e, n = !1, o) { const a = generateID(); let r; window.natively.isAndroidApp ? r = void 0 === t ? "ca-app-pub-3940256099942544/1033173712" : t : window.natively.isIOSApp && (r = void 0 === i ? "ca-app-pub-3940256099942544/4411468910" : i), this.loadAd = function (i) { const t = {}; t.unitId = void 0 === r ? "ca-app-pub-3940256099942544/4411468910" : r, window.natively.trigger(a, 14, i, "interstitialad_setup", t) }, this.showInterstitialAd = function (i) { window.natively.trigger(a, 14, (function (t) { if (i(t), "DID_DISMISS_AD" === t.event && n) { const i = {}; i.unitId = r, setTimeout((() => { window.natively.trigger(a, 14, o, "interstitialad_setup", i) }), 500) } }), "interstitialad_show", {}) }, this.interstitialIsReady = function (i) { window.natively.trigger(a, 14, i, "interstitialad_ready", {}) }, this.loadAd(e) } } class NativelyNFCService { constructor(i, t, e, n) { const o = generateID(); this.readAlertMessage = i, this.writeAlertMessage = t, this.readDetectedMessage = e, this.writeDetectedMessage = n, this.read = function (i) { let t = {}; t.alertMessage = void 0 === this.readAlertMessage ? "please set readAlertMessage" : this.readAlertMessage, t.detectedMessage = void 0 === this.readDetectedMessage ? "readDetectedMessage" : this.readDetectedMessage, window.natively.trigger(o, 15, i, "nfc_read", t) }, this.write = function (i, t, e) { let n = {}; n.alertMessage = void 0 === this.writeAlertMessage ? "please set writeAlertMessage" : this.writeAlertMessage, n.detectedMessage = void 0 === this.writeDetectedMessage ? "please set writeDetectedMessage" : this.writeDetectedMessage, n.recordData = void 0 === t ? "please set recordData" : t, n.recordId = void 0 === i ? "please set recordId" : i, window.natively.trigger(o, 15, e, "nfc_write", n) }, this.available = function (i) { window.natively.trigger(o, 15, i, "nfc_available", {}) } } } class NativelyAppleSignInService { constructor() { const i = generateID(); this.signin = function (t) { window.natively.trigger(i, 16, t, "apple_signin", {}) } } } function generateID() { return Date.now().toString(36) + Math.random().toString(36).substring(2) }
@@ -1 +1 @@
1
- window.natively={isDebug:false,min_app_version:0,app_version:0,injected:false,observers:[],isIOSApp:window.navigator.userAgent.includes("Natively/iOS"),isAndroidApp:window.navigator.userAgent.includes("Natively/Android"),setDebug:function(isDebug){window.natively.isDebug=isDebug},notify:function(min,current){window.natively.injected=true;if(min){window.natively.min_app_version=min}if(current){window.natively.app_version=current}const observers=window.natively.observers;if(natively.isDebug){console.log("[INFO] Notify observers: ",observers.length)}while(observers.length>0){const observer=observers.shift();observer()}},addObserver:function(fn){if(window.natively.injected){fn()}else{if(window.natively.isDebug){console.log(`[DEBUG] addObserver: ${fn}`)}window.natively.observers.push(fn)}},trigger:function(respId,minVersion,callback,method,body){const isTestVersion=window.natively.isDebug;if(!window.natively.injected){window.natively.addObserver((()=>{window.natively.trigger(respId,minVersion,callback,method,body)}));return}if(minVersion>window.natively.app_version){if(isTestVersion){alert(`[ERROR] Please rebuild the app to use this functionality. App Version: ${window.natively.app_version}, feature version: ${minVersion}`)}return}if(callback){let fullMethodName;if(respId){fullMethodName=method+"_response"+"_"+respId}else{fullMethodName=method+"_response"}window[fullMethodName]=function(resp,err){$agent.response();if(err.message&&isTestVersion){alert(`[ERROR] Error message: ${err.message}`);return}if(isTestVersion){console.log(`[DEBUG] Callback method: ${fullMethodName}, body: ${JSON.stringify(resp)}, respId: ${respId}`)}callback(resp)};if(body){body.response_id=respId}else{body={response_id:respId}}}if(isTestVersion){console.log(`[DEBUG] Trigger method: ${method}, body: ${JSON.stringify(body)}`)}$agent.trigger(method,body)},openLogger:function(){$agent.natively_logger()},openConsole:function(){window.natively.trigger(undefined,30,undefined,"app_console")},closeApp:function(){window.natively.trigger(undefined,11,undefined,"app_close")},showProgress:function(toggle){window.natively.trigger(undefined,11,undefined,"app_show_progress",{toggle:toggle})},shareImage(image_url){window.natively.trigger(undefined,0,undefined,"share_image",{url:image_url})},shareText(text){window.natively.trigger(undefined,0,undefined,"share_text",{text:text})},shareTextAndImage(text,image_url){window.natively.trigger(undefined,0,undefined,"share_text_and_image",{url:image_url,text:text})},shareFile(file_url){window.natively.trigger(undefined,2,undefined,"share_file",{url:file_url})},openExternalURL(url,external){const params={};params.url=typeof url==="undefined"?"https://buildnatively.com":url;const isExternal=typeof external==="undefined"?false:external;params.view=isExternal?"external":"web";window.natively.trigger(undefined,18,undefined,"open_link",params)},openExternalAppIOS(url){window.natively.trigger(undefined,0,undefined,"open_app",{url:url})},openAppSettings(){window.natively.trigger(undefined,0,undefined,"open_appsettings")},hapticPatternIOS(pattern,delay){window.natively.trigger(undefined,7,undefined,"haptic_pattern",{pattern:pattern,delay:delay})},hapticImpactIOS(type){window.natively.trigger(undefined,7,undefined,"haptic_impact",{type:type})},hapticNotificationIOS(type){window.natively.trigger(undefined,7,undefined,"haptic_notification",{type:type})},showAppToast(type,text){const params={};params.text=typeof text==="undefined"?"":text;params.type=typeof type==="undefined"?"DEFAULT":type;window.natively.trigger(undefined,0,undefined,"show_toast",params)},showAppBanner(type,title,description){const params={};params.type=typeof type==="undefined"?"INFO":type;params.title=typeof title==="undefined"?"":title;params.description=typeof description==="undefined"?"":description;window.natively.trigger(undefined,0,undefined,"show_banner",params)},requestAppReview(){window.natively.trigger(undefined,0,undefined,"request_review")},setAppBackgroundColor(color){const params={color:color};window.natively.trigger(undefined,1,undefined,"app_background",params)},setAppProgressColor(color){const params={color:color};window.natively.trigger(undefined,1,undefined,"app_progress",params)},setAppSwipeNavigationIOS(toggle){const params={toggle:toggle};window.natively.trigger(undefined,1,undefined,"app_navigation",params)},setAppPullToRefresh(toggle){const params={toggle:toggle};window.natively.trigger(undefined,1,undefined,"app_pull",params)},setAppOrientation(orientation){const params={orientation:orientation};window.natively.trigger(undefined,3,undefined,"app_orientation",params)},setAppStatusBarStyleIOS(style){const params={style:style};window.natively.trigger(undefined,2,undefined,"status_bar_style",params)},hideLoadingScreen(){const show_loader=false;const auto_hide=true;const params={show_loader:show_loader,auto_hide:auto_hide};window.natively.trigger(undefined,17,undefined,"loading_screen",params)},showLoadingScreen(autoHide){const show_loader=true;const auto_hide=typeof autoHide==="undefined"?false:autoHide;const params={show_loader:show_loader,auto_hide:auto_hide};window.natively.trigger(undefined,17,undefined,"loading_screen",params)},async sendPushNotification(appId,payload,player_ids,isPreview){const filtered=player_ids.filter((id=>id.length>0));const include_player_ids=[...new Set(filtered)];let notification={app_id:isPreview?"be83022a-1d08-45d0-a07a-0c3655666e17":appId,include_player_ids:include_player_ids};if(payload.template_id){notification.template_id=payload.template_id}else{notification.headings={};notification.headings.en=payload.title||"Empty Title";notification.contents={};notification.contents.en=payload.message||"Empty Message";if(payload.subtitle){notification.subtitle={};notification.subtitle.en=payload.subtitle}if(payload.redirect_url){notification.url=payload.redirect_url}}const options={method:"POST",headers:{"Content-type":"application/json"},body:JSON.stringify(notification)};return await fetch("https://onesignal.com/api/v1/notifications",options)}};window.natively.addObserver((()=>window.natively.trigger(undefined,0,(resp=>{window.natively.min_app_version=resp.minSDKVersion;window.natively.app_version=resp.sdkVersion}),"app_info",{})));class NativelyInfo{constructor(){const id=generateID();this.browserInfo=function(){const isNativeApp=typeof $agent!=="undefined";const isIOSApp=window.navigator.userAgent.includes("Natively/iOS");const isAndroidApp=window.navigator.userAgent.includes("Natively/Android");return{isNativeApp:isNativeApp,isIOSApp:isIOSApp,isAndroidApp:isAndroidApp}};this.getAppInfo=function(app_info_callback){window.natively.trigger(id,0,app_info_callback,"app_info")};this.connectivity=function(connectivity_callback){window.natively.trigger(undefined,0,connectivity_callback,"connectivity")};this.app_state=function(app_state_callback){window.natively.trigger(undefined,19,app_state_callback,"app_state")}}}class NativelyClipboard{constructor(){const id=generateID();this.copy=function(text){window.natively.trigger(undefined,11,undefined,"clipboard_copy",{text:text})};this.paste=function(paste_callback){window.natively.trigger(id,11,paste_callback,"clipboard_paste")}}}class NativelyPagesCache{constructor(){const id=generateID();this.currentPageCached=function(current_page_cached_callback){window.natively.trigger(id,4,current_page_cached_callback,"current_page_cached")};this.storeCurrentPage=function(store_current_page_callback){window.natively.trigger(id,4,store_current_page_callback,"store_current_page")};this.resetCurrentPage=function(reset_current_page_callback){window.natively.trigger(id,4,reset_current_page_callback,"reset_current_page")};this.resetAll=function(reset_all_callback){window.natively.trigger(id,4,reset_all_callback,"reset_all")}}}class NativelyNotifications{constructor(){const id=generateID();this.getOneSignalId=function(onesignal_playerid_callback){window.natively.trigger(id,0,onesignal_playerid_callback,"onesignal_playerid")};this.requestPermission=function(fallbackToSettings,push_register_callback){window.natively.trigger(id,0,push_register_callback,"push_register",{fallbackToSettings:fallbackToSettings})};this.getPermissionStatus=function(push_permission_callback){window.natively.trigger(id,0,push_permission_callback,"push_permission")}}}class NativelyGeolocation{constructor(){const id=generateID();this.getUserGeolocation=function(distance,geolocation_callback){window.natively.trigger(id,0,geolocation_callback,"geolocation",{distance:distance})};this.requestPermission=function(geo_register_callback){window.natively.trigger(id,0,geo_register_callback,"geo_register")};this.getPermissionStatus=function(geo_permission_callback){window.natively.trigger(id,0,geo_permission_callback,"geo_permission")}}}class NativelyLocation{constructor(){const id=generateID();this.current=function(minAccuracyIOS,accuracyTypeIOS,priority_android,location_callback){window.natively.trigger(id,12,location_callback,"location_current",{minAccuracy:minAccuracyIOS,accuracyType:accuracyTypeIOS,priority:priority_android})};this.permission=function(location_permission_callback){window.natively.trigger(id,6,location_permission_callback,"location_permission")};this.start=function(interval,minAccuracyIOS,accuracyTypeIOS,priority_android,location_callback){window.natively.trigger(id,12,location_callback,"location_start",{minAccuracy:minAccuracyIOS,accuracyType:accuracyTypeIOS,priority:priority_android,interval:interval})};this.stop=function(){window.natively.trigger(id,3,undefined,"location_stop",{})};this.startBackground=function(interval,minAccuracyIOS,accuracyTypeIOS,priority_android,responseIdentifier,location_bg_callback){const params={};params.identifier=typeof responseIdentifier==="undefined"?"empty":responseIdentifier;params.interval=typeof interval==="undefined"?1e3*60:interval;params.minAccuracy=typeof minAccuracyIOS==="undefined"?50:minAccuracyIOS;params.accuracyType=typeof accuracyTypeIOS==="undefined"?"Best":accuracyTypeIOS;params.priority=typeof priority_android==="undefined"?"BALANCED":priority_android;window.natively.trigger(id,12,location_bg_callback,"location_start_bg",params)};this.statusBackground=function(location_bg_status_callback){window.natively.trigger(id,20,location_bg_status_callback,"location_status_bg",{})};this.stopBackground=function(location_bg_callback){window.natively.trigger(id,4,location_bg_callback,"location_stop_bg",{})}}}class NativelyMessage{constructor(){const id=generateID();this.sendSMS=function(body,recipient,send_sms_callback){const params={};params.body=typeof body==="undefined"?"":body;params.recipient=typeof recipient==="undefined"?"":recipient;window.natively.trigger(id,0,send_sms_callback,"send_sms",params)};this.sendEmail=function(subject,body,recipient,send_email_callback){const params={};params.subject=typeof subject==="undefined"?"":subject;params.body=typeof body==="undefined"?"":body;params.recipient=typeof recipient==="undefined"?"":recipient;window.natively.trigger(id,0,send_email_callback,"send_email",params)}}}class NativelyStorage{constructor(){const id=generateID();this.setStorageValue=function(key,value){window.natively.trigger(id,0,undefined,"set_storage_value",{key:key,value:value})};this.getStorageValue=function(key,get_storage_value_callback){window.natively.trigger(id,0,get_storage_value_callback,"get_storage_value",{key:key})};this.removeStorageValue=function(key){window.natively.trigger(id,0,undefined,"remove_storage_value",{key:key})};this.resetStorage=function(){window.natively.trigger(id,0,undefined,"reset_storage")}}}class NativelyBiometrics{constructor(allowPass){this.allowPass=allowPass;const id=generateID();this.checkBiometricsSupport=function(biometrics_support_callback){window.natively.trigger(id,0,biometrics_support_callback,"biometrics_support",{allowPass:allowPass})};this.checkCredentials=function(biometrics_has_credentials_callback){window.natively.trigger(id,0,biometrics_has_credentials_callback,"biometrics_has_credentials")};this.verifyUserIdentify=function(biometrics_verify_callback){window.natively.trigger(id,0,biometrics_verify_callback,"biometrics_verify",{allowPass:allowPass})};this.getUserCredentials=function(biometrics_auth_callback){window.natively.trigger(id,0,biometrics_auth_callback,"biometrics_auth",{allowPass:allowPass})};this.removeUserCredentials=function(biometrics_remove_credentials_callback){window.natively.trigger(id,0,biometrics_remove_credentials_callback,"biometrics_remove_credentials")};this.saveUserCredentials=function(login,password,biometrics_auth_callback){window.natively.trigger(id,0,biometrics_auth_callback,"biometrics_auth",{allowPass:allowPass,login:login,password:password})}}}class NativelyDatePicker{constructor(){const id=generateID();this.showDatePicker=function(title,description,type,style,datepicker_callback){let params={};params.type=typeof type==="undefined"?"DATE":type;params.style=typeof style==="undefined"?"LIGHT":style;params.title=typeof title==="undefined"?"":title;params.description=typeof description==="undefined"?"":description;window.natively.trigger(id,0,datepicker_callback,"datepicker",params)}}}class NativelyCamera{constructor(){const id=generateID();this.showCamera=function(type,quality,camera,open_camera_callback){let params={};params.type=typeof type==="undefined"?"photo":type;params.quality=typeof quality==="undefined"?"high":quality;params.camera=typeof camera==="undefined"?"BACK":camera;window.natively.trigger(id,2,open_camera_callback,"open_camera",params)}}}class NativelyHealth{constructor(){const id=generateID();this.available=function(available_callback){window.natively.trigger(id,10,available_callback,"health_available",{})};this.requestAuthorization=function(write_data_types,read_data_types,request_callback){window.natively.trigger(id,10,request_callback,"health_register",{write_data_types:write_data_types,read_data_types:read_data_types})};this.permissionStatus=function(data_type,callback){window.natively.trigger(id,10,callback,"health_permission",{data_type:data_type})};this.getAllCharacteristics=function(callback){window.natively.trigger(id,10,callback,"health_get_all_characteristics",{})};this.getStatisticQuantity=function(data_type,interval,start_date,end_date,callback){const obj={data_type:data_type,interval:interval};if(typeof start_date!=="undefined"){obj.start_date=start_date.getTime()}if(typeof end_date!=="undefined"){obj.end_date=end_date.getTime()}window.natively.trigger(id,10,callback,"health_get_statistic_quantity",obj)};this.getDailySleepAnalysis=function(start_date,end_date,limit,callback){const obj={limit:limit||100};if(typeof start_date!=="undefined"){obj.start_date=start_date.getTime()}if(typeof end_date!=="undefined"){obj.end_date=end_date.getTime()}window.natively.trigger(id,10,callback,"health_get_daily_sleep_analysis",obj)};this.getWorkouts=function(start_date,end_date,limit,callback){const obj={limit:limit||100};if(typeof start_date!=="undefined"){obj.start_date=start_date.getTime()}if(typeof end_date!=="undefined"){obj.end_date=end_date.getTime()}window.natively.trigger(id,21,callback,"health_get_workouts",obj)};this.getActivitySummary=function(start_date,end_date,callback){const obj={};if(typeof start_date!=="undefined"){obj.start_date=start_date.getTime()}if(typeof end_date!=="undefined"){obj.end_date=end_date.getTime()}window.natively.trigger(id,10,callback,"health_get_activity_summary",obj)}}}class NativelyScanner{constructor(){const id=generateID();this.showScanner=function(open_scanner_callback){window.natively.trigger(id,2,open_scanner_callback,"open_scanner",{})}}}class NativelyPurchases{constructor(){const id=generateID();this.login=function(login,customerEmail,login_callback){const email=typeof customerEmail==="undefined"?"":customerEmail;window.natively.trigger(id,3,login_callback,"purchases_login",{login:login,email:email})};this.logout=function(logout_callback){window.natively.trigger(id,3,logout_callback,"purchases_logout",{})};this.customerId=function(customer_id_callback){window.natively.trigger(id,3,customer_id_callback,"purchases_customerid",{})};this.restore=function(restore_callback){window.natively.trigger(id,10,restore_callback,"purchases_restore",{})};this.purchasePackage=function(packageId,purchase_callback){window.natively.trigger(id,3,purchase_callback,"purchases_package",{packageId:packageId})};this.packagePrice=function(packageId,purchase_callback){window.natively.trigger(id,8,purchase_callback,"purchases_price",{packageId:packageId})}}}class NativelyContacts{constructor(){const id=generateID();this.getAllContacts=function(contacts_all_callback){window.natively.trigger(id,3,contacts_all_callback,"contacts_all",{})};this.createContact=function(firstName,lastName,email,phone,contacts_save_callback){let params={firstName:firstName};params.lastName=typeof lastName==="undefined"?"":lastName;params.email=typeof email==="undefined"?"":email;params.phone=typeof phone==="undefined"?"":phone;window.natively.trigger(id,3,contacts_save_callback,"contacts_save",params)}}}class NativelyMediaPicker{constructor(){const id=generateID();this.showMediaPicker=function(mediapicker_callback){window.natively.trigger(id,8,mediapicker_callback,"mediapicker",{})}}}class NativelyAudioRecorder{constructor(){const id=generateID();this.showRecorder=function(max_duration,record_callback){let params={};params.max_duration=typeof max_duration==="undefined"?0:max_duration;window.natively.trigger(id,13,record_callback,"record_start",params)}}}class NativelyAdmobBanner{constructor(config={iOSUnitId:"ca-app-pub-3940256099942544/2934735716",androidUnitId:"ca-app-pub-3940256099942544/6300978111",position:"BOTTOM",sizeType:"AUTO",custom_width:320,custom_height:50},setup_callback=undefined,preload_ad=false,preload_callback=undefined,show_ad=false,show_callback=undefined){const id=generateID();const params={};if(window.natively.isAndroidApp){params.unitId=typeof config.androidUnitId==="undefined"?"ca-app-pub-3940256099942544/6300978111":config.androidUnitId}else if(window.natively.isIOSApp){params.unitId=typeof config.iOSUnitId==="undefined"?"ca-app-pub-3940256099942544/2934735716":config.iOSUnitId}params.position=typeof config.position==="undefined"?"BOTTOM":config.position;params.sizeType=typeof config.sizeType==="undefined"?"AUTO":config.sizeType;params.width=typeof config.custom_width==="undefined"?320:config.width;params.height=typeof config.custom_height==="undefined"?50:config.height;window.natively.trigger(id,14,(function(resp){if(typeof setup_callback!=="undefined"){setup_callback(resp)}if(preload_ad){window.natively.trigger(id,14,(function(resp){if(typeof preload_callback!=="undefined"){preload_callback(resp)}if(show_ad){window.natively.trigger(id,14,show_callback,"bannerad_show",{})}}),"bannerad_load",{})}}),"bannerad_setup",params);this.loadAd=function(callback){window.natively.trigger(id,14,callback,"bannerad_load",{})};this.showBanner=function(callback){window.natively.trigger(id,14,callback,"bannerad_show",{})};this.hideBanner=function(callback){window.natively.trigger(id,14,callback,"bannerad_hide",{})};this.bannerIsReady=function(callback){window.natively.trigger(id,14,callback,"bannerad_ready",{})};this.bannerIsVisible=function(callback){window.natively.trigger(id,14,callback,"bannerad_visible",{})}}}class NativelyAdmobInterstitial{constructor(iOSUnitId="ca-app-pub-3940256099942544/4411468910",androidUnitId="ca-app-pub-3940256099942544/1033173712",setup_callback=undefined,auto_ad_reload=false,auto_ad_reload_callback=undefined){const id=generateID();let unitId;if(window.natively.isAndroidApp){unitId=typeof androidUnitId==="undefined"?"ca-app-pub-3940256099942544/1033173712":androidUnitId}else if(window.natively.isIOSApp){unitId=typeof iOSUnitId==="undefined"?"ca-app-pub-3940256099942544/4411468910":iOSUnitId}this.loadAd=function(callback){const params={};params.unitId=typeof unitId==="undefined"?"ca-app-pub-3940256099942544/4411468910":unitId;window.natively.trigger(id,14,callback,"interstitialad_setup",params)};this.showInterstitialAd=function(callback){window.natively.trigger(id,14,(function(resp){callback(resp);if(resp.event==="DID_DISMISS_AD"&&auto_ad_reload){const params={};params.unitId=unitId;setTimeout((()=>{window.natively.trigger(id,14,auto_ad_reload_callback,"interstitialad_setup",params)}),500)}}),"interstitialad_show",{})};this.interstitialIsReady=function(callback){window.natively.trigger(id,14,callback,"interstitialad_ready",{})};this.loadAd(setup_callback)}}class NativelyNFCService{constructor(readAlertMessage,writeAlertMessage,readDetectedMessage,writeDetectedMessage){const id=generateID();this.readAlertMessage=readAlertMessage;this.writeAlertMessage=writeAlertMessage;this.readDetectedMessage=readDetectedMessage;this.writeDetectedMessage=writeDetectedMessage;this.read=function(callback){let params={};params.alertMessage=typeof this.readAlertMessage==="undefined"?"please set readAlertMessage":this.readAlertMessage;params.detectedMessage=typeof this.readDetectedMessage==="undefined"?"readDetectedMessage":this.readDetectedMessage;window.natively.trigger(id,15,callback,"nfc_read",params)};this.write=function(recordId,recordData,callback){let params={};params.alertMessage=typeof this.writeAlertMessage==="undefined"?"please set writeAlertMessage":this.writeAlertMessage;params.detectedMessage=typeof this.writeDetectedMessage==="undefined"?"please set writeDetectedMessage":this.writeDetectedMessage;params.recordData=typeof recordData==="undefined"?"please set recordData":recordData;params.recordId=typeof recordId==="undefined"?"please set recordId":recordId;window.natively.trigger(id,15,callback,"nfc_write",params)};this.available=function(callback){let params={};window.natively.trigger(id,15,callback,"nfc_available",params)}}}class NativelyAppleSignInService{constructor(){const id=generateID();this.signin=function(callback){let params={};window.natively.trigger(id,16,callback,"apple_signin",params)}}}function generateID(){return Date.now().toString(36)+Math.random().toString(36).substring(2)}export{NativelyAdmobBanner,NativelyAdmobInterstitial,NativelyAppleSignInService,NativelyAudioRecorder,NativelyBiometrics,NativelyCamera,NativelyClipboard,NativelyContacts,NativelyDatePicker,NativelyGeolocation,NativelyHealth,NativelyInfo,NativelyLocation,NativelyMediaPicker,NativelyMessage,NativelyNFCService,NativelyNotifications,NativelyPagesCache,NativelyPurchases,NativelyScanner,NativelyStorage};
1
+ window.natively = { isDebug: !1, min_app_version: 0, app_version: 0, injected: !1, observers: [], isIOSApp: window.navigator.userAgent.includes("Natively/iOS"), isAndroidApp: window.navigator.userAgent.includes("Natively/Android"), setDebug: function (e) { window.natively.isDebug = e }, notify: function (e, t) { window.natively.injected = !0, e && (window.natively.min_app_version = e), t && (window.natively.app_version = t); let i = window.natively.observers; for (natively.isDebug && console.log("[INFO] Notify observers: ", i.length); i.length > 0;) { let a = i.shift(); a() } }, addObserver: function (e) { window.natively.injected ? e() : (window.natively.isDebug && console.log(`[DEBUG] addObserver: ${e}`), window.natively.observers.push(e)) }, trigger: function (e, t, i, a, r) { let n = window.natively.isDebug; if (!window.natively.injected) { window.natively.addObserver(() => { window.natively.trigger(e, t, i, a, r) }); return } if (t > window.natively.app_version) { n && alert(`[ERROR] Please rebuild the app to use this functionality. App Version: ${window.natively.app_version}, feature version: ${t}`); return } if (i) { let o; o = e ? a + "_response_" + e : a + "_response", window[o] = function (t, a) { if ($agent.response(), a.message && n) { alert(`[ERROR] Error message: ${a.message}`); return } n && console.log(`[DEBUG] Callback method: ${o}, body: ${JSON.stringify(t)}, respId: ${e}`), i(t) }, r ? r.response_id = e : r = { response_id: e } } n && console.log(`[DEBUG] Trigger method: ${a}, body: ${JSON.stringify(r)}`), $agent.trigger(a, r) }, openLogger: function () { $agent.natively_logger() }, openConsole: function () { window.natively.trigger(void 0, 22, void 0, "app_console") }, closeApp: function () { window.natively.trigger(void 0, 11, void 0, "app_close") }, showProgress: function (e) { window.natively.trigger(void 0, 11, void 0, "app_show_progress", { toggle: e }) }, shareImage(e) { window.natively.trigger(void 0, 0, void 0, "share_image", { url: e }) }, shareText(e) { window.natively.trigger(void 0, 0, void 0, "share_text", { text: e }) }, shareTextAndImage(e, t) { window.natively.trigger(void 0, 0, void 0, "share_text_and_image", { url: t, text: e }) }, shareFile(e) { window.natively.trigger(void 0, 2, void 0, "share_file", { url: e }) }, openExternalURL(e, t) { let i = {}; i.url = void 0 === e ? "https://buildnatively.com" : e, i.view = void 0 !== t && t ? "external" : "web", window.natively.trigger(void 0, 18, void 0, "open_link", i) }, openExternalAppIOS(e) { window.natively.trigger(void 0, 0, void 0, "open_app", { url: e }) }, openExternalApp(e) { window.natively.trigger(void 0, 22, void 0, "open_app", { url: e }) }, openAppSettings() { window.natively.trigger(void 0, 0, void 0, "open_appsettings") }, hapticPatternIOS(e, t) { window.natively.trigger(void 0, 7, void 0, "haptic_pattern", { pattern: e, delay: t }) }, hapticImpactIOS(e) { window.natively.trigger(void 0, 7, void 0, "haptic_impact", { type: e }) }, hapticNotificationIOS(e) { window.natively.trigger(void 0, 7, void 0, "haptic_notification", { type: e }) }, hapticPattern(e, t) { window.natively.trigger(void 0, 22, void 0, "haptic_pattern", { pattern: e, delay: t }) }, hapticImpact(e) { window.natively.trigger(void 0, 22, void 0, "haptic_impact", { type: e }) }, hapticNotification(e) { window.natively.trigger(void 0, 22, void 0, "haptic_notification", { type: e }) }, showAppToast(e, t) { let i = {}; i.text = void 0 === t ? "" : t, i.type = void 0 === e ? "DEFAULT" : e, window.natively.trigger(void 0, 0, void 0, "show_toast", i) }, showAppBanner(e, t, i) { let a = {}; a.type = void 0 === e ? "INFO" : e, a.title = void 0 === t ? "" : t, a.description = void 0 === i ? "" : i, window.natively.trigger(void 0, 0, void 0, "show_banner", a) }, requestAppReview() { window.natively.trigger(void 0, 0, void 0, "request_review") }, setAppBackgroundColor(e) { window.natively.trigger(void 0, 1, void 0, "app_background", { color: e }) }, setAppProgressColor(e) { window.natively.trigger(void 0, 1, void 0, "app_progress", { color: e }) }, setAppSwipeNavigationIOS(e) { window.natively.trigger(void 0, 1, void 0, "app_navigation", { toggle: e }) }, setAppSwipeNavigation(e) { window.natively.trigger(void 0, 22, void 0, "app_navigation", { toggle: e }) }, setAppPullToRefresh(e) { window.natively.trigger(void 0, 1, void 0, "app_pull", { toggle: e }) }, setAppOrientation(e) { window.natively.trigger(void 0, 3, void 0, "app_orientation", { orientation: e }) }, setAppStatusBarStyleIOS(e) { window.natively.trigger(void 0, 2, void 0, "status_bar_style", { style: e }) }, setAppStatusBarStyle(e) { window.natively.trigger(void 0, 22, void 0, "status_bar_style", { style: e }) }, hideLoadingScreen() { window.natively.trigger(void 0, 17, void 0, "loading_screen", { show_loader: !1, auto_hide: !0 }) }, showLoadingScreen(e) { window.natively.trigger(void 0, 17, void 0, "loading_screen", { show_loader: !0, auto_hide: void 0 !== e && e }) }, async sendPushNotification(e, t, i, a) { let r = i.filter(e => e.length > 0), n = [...new Set(r)], o = { app_id: a ? "be83022a-1d08-45d0-a07a-0c3655666e17" : e, include_player_ids: n }; t.template_id ? o.template_id = t.template_id : (o.headings = {}, o.headings.en = t.title || "Empty Title", o.contents = {}, o.contents.en = t.message || "Empty Message", t.subtitle && (o.subtitle = {}, o.subtitle.en = t.subtitle), t.redirect_url && (o.url = t.redirect_url)); let s = { method: "POST", headers: { "Content-type": "application/json" }, body: JSON.stringify(o) }; return await fetch("https://onesignal.com/api/v1/notifications", s) } }, window.natively.addObserver(() => window.natively.trigger(void 0, 0, e => { window.natively.min_app_version = e.minSDKVersion, window.natively.app_version = e.sdkVersion }, "app_info", {})); class NativelyInfo { constructor() { let e = generateID(); this.browserInfo = function () { let e = "undefined" != typeof $agent, t = window.navigator.userAgent.includes("Natively/iOS"), i = window.navigator.userAgent.includes("Natively/Android"); return { isNativeApp: e, isIOSApp: t, isAndroidApp: i } }, this.getAppInfo = function (t) { window.natively.trigger(e, 0, t, "app_info") }, this.connectivity = function (e) { window.natively.trigger(void 0, 0, e, "connectivity") }, this.app_state = function (e) { window.natively.trigger(void 0, 19, e, "app_state") } } } class NativelyClipboard { constructor() { let e = generateID(); this.copy = function (e) { window.natively.trigger(void 0, 11, void 0, "clipboard_copy", { text: e }) }, this.paste = function (t) { window.natively.trigger(e, 11, t, "clipboard_paste") } } } class NativelyPagesCache { constructor() { let e = generateID(); this.currentPageCached = function (t) { window.natively.trigger(e, 4, t, "current_page_cached") }, this.storeCurrentPage = function (t) { window.natively.trigger(e, 4, t, "store_current_page") }, this.resetCurrentPage = function (t) { window.natively.trigger(e, 4, t, "reset_current_page") }, this.resetAll = function (t) { window.natively.trigger(e, 4, t, "reset_all") } } } class NativelyNotifications { constructor() { let e = generateID(); this.getOneSignalId = function (t) { window.natively.trigger(e, 0, t, "onesignal_playerid") }, this.requestPermission = function (t, i) { window.natively.trigger(e, 0, i, "push_register", { fallbackToSettings: t }) }, this.getPermissionStatus = function (t) { window.natively.trigger(e, 0, t, "push_permission") } } } class NativelyGeolocation { constructor() { let e = generateID(); this.getUserGeolocation = function (t, i) { window.natively.trigger(e, 0, i, "geolocation", { distance: t }) }, this.requestPermission = function (t) { window.natively.trigger(e, 0, t, "geo_register") }, this.getPermissionStatus = function (t) { window.natively.trigger(e, 0, t, "geo_permission") } } } class NativelyLocation { constructor() { let e = generateID(); this.current = function (t, i, a, r) { window.natively.trigger(e, 12, r, "location_current", { minAccuracy: t, accuracyType: i, priority: a }) }, this.permission = function (t) { window.natively.trigger(e, 6, t, "location_permission") }, this.start = function (t, i, a, r, n) { window.natively.trigger(e, 12, n, "location_start", { minAccuracy: i, accuracyType: a, priority: r, interval: t }) }, this.stop = function () { window.natively.trigger(e, 3, void 0, "location_stop", {}) }, this.startBackground = function (t, i, a, r, n, o) { let s = {}; s.identifier = void 0 === n ? "empty" : n, s.interval = void 0 === t ? 6e4 : t, s.minAccuracy = void 0 === i ? 50 : i, s.accuracyType = void 0 === a ? "Best" : a, s.priority = void 0 === r ? "BALANCED" : r, window.natively.trigger(e, 12, o, "location_start_bg", s) }, this.statusBackground = function (t) { window.natively.trigger(e, 20, t, "location_status_bg", {}) }, this.stopBackground = function (t) { window.natively.trigger(e, 4, t, "location_stop_bg", {}) } } } class NativelyMessage { constructor() { let e = generateID(); this.sendSMS = function (t, i, a) { let r = {}; r.body = void 0 === t ? "" : t, r.recipient = void 0 === i ? "" : i, window.natively.trigger(e, 0, a, "send_sms", r) }, this.sendEmail = function (t, i, a, r) { let n = {}; n.subject = void 0 === t ? "" : t, n.body = void 0 === i ? "" : i, n.recipient = void 0 === a ? "" : a, window.natively.trigger(e, 0, r, "send_email", n) } } } class NativelyStorage { constructor() { let e = generateID(); this.setStorageValue = function (t, i) { window.natively.trigger(e, 0, void 0, "set_storage_value", { key: t, value: i }) }, this.getStorageValue = function (t, i) { window.natively.trigger(e, 0, i, "get_storage_value", { key: t }) }, this.removeStorageValue = function (t) { window.natively.trigger(e, 0, void 0, "remove_storage_value", { key: t }) }, this.resetStorage = function () { window.natively.trigger(e, 0, void 0, "reset_storage") } } } class NativelyBiometrics { constructor(e) { this.allowPass = e; let t = generateID(); this.checkBiometricsSupport = function (i) { window.natively.trigger(t, 0, i, "biometrics_support", { allowPass: e }) }, this.checkCredentials = function (e) { window.natively.trigger(t, 0, e, "biometrics_has_credentials") }, this.verifyUserIdentify = function (i) { window.natively.trigger(t, 0, i, "biometrics_verify", { allowPass: e }) }, this.getUserCredentials = function (i) { window.natively.trigger(t, 0, i, "biometrics_auth", { allowPass: e }) }, this.removeUserCredentials = function (e) { window.natively.trigger(t, 0, e, "biometrics_remove_credentials") }, this.saveUserCredentials = function (i, a, r) { window.natively.trigger(t, 0, r, "biometrics_auth", { allowPass: e, login: i, password: a }) } } } class NativelyDatePicker { constructor() { let e = generateID(); this.showDatePicker = function (t, i, a, r, n) { let o = {}; o.type = void 0 === a ? "DATE" : a, o.style = void 0 === r ? "LIGHT" : r, o.title = void 0 === t ? "" : t, o.description = void 0 === i ? "" : i, window.natively.trigger(e, 0, n, "datepicker", o) } } } class NativelyCamera { constructor() { let e = generateID(); this.showCamera = function (t, i, a, r) { let n = {}; n.type = void 0 === t ? "photo" : t, n.quality = void 0 === i ? "high" : i, n.camera = void 0 === a ? "BACK" : a, window.natively.trigger(e, 2, r, "open_camera", n) } } } class NativelyHealth { constructor() { let e = generateID(); this.available = function (t) { window.natively.trigger(e, 10, t, "health_available", {}) }, this.requestAuthorization = function (t, i, a) { window.natively.trigger(e, 10, a, "health_register", { write_data_types: t, read_data_types: i }) }, this.permissionStatus = function (t, i) { window.natively.trigger(e, 10, i, "health_permission", { data_type: t }) }, this.getAllCharacteristics = function (t) { window.natively.trigger(e, 10, t, "health_get_all_characteristics", {}) }, this.getStatisticQuantity = function (t, i, a, r, n) { let o = { data_type: t, interval: i }; void 0 !== a && (o.start_date = a.getTime()), void 0 !== r && (o.end_date = r.getTime()), window.natively.trigger(e, 10, n, "health_get_statistic_quantity", o) }, this.getDailySleepAnalysis = function (t, i, a, r) { let n = { limit: a || 100 }; void 0 !== t && (n.start_date = t.getTime()), void 0 !== i && (n.end_date = i.getTime()), window.natively.trigger(e, 10, r, "health_get_daily_sleep_analysis", n) }, this.getWorkouts = function (t, i, a, r) { let n = { limit: a || 100 }; void 0 !== t && (n.start_date = t.getTime()), void 0 !== i && (n.end_date = i.getTime()), window.natively.trigger(e, 21, r, "health_get_workouts", n) }, this.getActivitySummary = function (t, i, a) { let r = {}; void 0 !== t && (r.start_date = t.getTime()), void 0 !== i && (r.end_date = i.getTime()), window.natively.trigger(e, 10, a, "health_get_activity_summary", r) } } } class NativelyScanner { constructor() { let e = generateID(); this.showScanner = function (t) { window.natively.trigger(e, 2, t, "open_scanner", {}) } } } class NativelyPurchases { constructor() { let e = generateID(); this.login = function (t, i, a) { window.natively.trigger(e, 3, a, "purchases_login", { login: t, email: void 0 === i ? "" : i }) }, this.logout = function (t) { window.natively.trigger(e, 3, t, "purchases_logout", {}) }, this.customerId = function (t) { window.natively.trigger(e, 3, t, "purchases_customerid", {}) }, this.restore = function (t) { window.natively.trigger(e, 10, t, "purchases_restore", {}) }, this.purchasePackage = function (t, i) { window.natively.trigger(e, 3, i, "purchases_package", { packageId: t }) }, this.packagePrice = function (t, i) { window.natively.trigger(e, 8, i, "purchases_price", { packageId: t }) } } } class NativelyContacts { constructor() { let e = generateID(); this.getAllContacts = function (t) { window.natively.trigger(e, 3, t, "contacts_all", {}) }, this.createContact = function (t, i, a, r, n) { let o = { firstName: t }; o.lastName = void 0 === i ? "" : i, o.email = void 0 === a ? "" : a, o.phone = void 0 === r ? "" : r, window.natively.trigger(e, 3, n, "contacts_save", o) } } } class NativelyMediaPicker { constructor() { let e = generateID(); this.showMediaPicker = function (t) { window.natively.trigger(e, 8, t, "mediapicker", {}) } } } class NativelyAudioRecorder { constructor() { let e = generateID(); this.showRecorder = function (t, i) { let a = {}; a.max_duration = void 0 === t ? 0 : t, window.natively.trigger(e, 13, i, "record_start", a) } } } class NativelyAdmobBanner { constructor(e, t, i = !1, a, r = !1, n) { let o = generateID(), s = {}; window.natively.isAndroidApp ? s.unitId = void 0 === e.androidUnitId ? "ca-app-pub-3940256099942544/6300978111" : e.androidUnitId : window.natively.isIOSApp && (s.unitId = void 0 === e.iOSUnitId ? "ca-app-pub-3940256099942544/2934735716" : e.iOSUnitId), s.position = void 0 === e.position ? "BOTTOM" : e.position, s.sizeType = void 0 === e.sizeType ? "AUTO" : e.sizeType, s.width = void 0 === e.custom_width ? 320 : e.custom_width, s.height = void 0 === e.custom_height ? 50 : e.custom_height, window.natively.trigger(o, 14, function (e) { void 0 !== t && t(e), i && window.natively.trigger(o, 14, function (e) { void 0 !== a && a(e), r && window.natively.trigger(o, 14, n, "bannerad_show", {}) }, "bannerad_load", {}) }, "bannerad_setup", s), this.loadAd = function (e) { window.natively.trigger(o, 14, e, "bannerad_load", {}) }, this.showBanner = function (e) { window.natively.trigger(o, 14, e, "bannerad_show", {}) }, this.hideBanner = function (e) { window.natively.trigger(o, 14, e, "bannerad_hide", {}) }, this.bannerIsReady = function (e) { window.natively.trigger(o, 14, e, "bannerad_ready", {}) }, this.bannerIsVisible = function (e) { window.natively.trigger(o, 14, e, "bannerad_visible", {}) } } } class NativelyAdmobInterstitial { constructor(e = "ca-app-pub-3940256099942544/4411468910", t = "ca-app-pub-3940256099942544/1033173712", i, a = !1, r) { let n = generateID(), o; window.natively.isAndroidApp ? o = void 0 === t ? "ca-app-pub-3940256099942544/1033173712" : t : window.natively.isIOSApp && (o = void 0 === e ? "ca-app-pub-3940256099942544/4411468910" : e), this.loadAd = function (e) { let t = {}; t.unitId = void 0 === o ? "ca-app-pub-3940256099942544/4411468910" : o, window.natively.trigger(n, 14, e, "interstitialad_setup", t) }, this.showInterstitialAd = function (e) { window.natively.trigger(n, 14, function (t) { if (e(t), "DID_DISMISS_AD" === t.event && a) { let i = {}; i.unitId = o, setTimeout(() => { window.natively.trigger(n, 14, r, "interstitialad_setup", i) }, 500) } }, "interstitialad_show", {}) }, this.interstitialIsReady = function (e) { window.natively.trigger(n, 14, e, "interstitialad_ready", {}) }, this.loadAd(i) } } class NativelyNFCService { constructor(e, t, i, a) { let r = generateID(); this.readAlertMessage = e, this.writeAlertMessage = t, this.readDetectedMessage = i, this.writeDetectedMessage = a, this.read = function (e) { let t = {}; t.alertMessage = void 0 === this.readAlertMessage ? "please set readAlertMessage" : this.readAlertMessage, t.detectedMessage = void 0 === this.readDetectedMessage ? "readDetectedMessage" : this.readDetectedMessage, window.natively.trigger(r, 15, e, "nfc_read", t) }, this.write = function (e, t, i) { let a = {}; a.alertMessage = void 0 === this.writeAlertMessage ? "please set writeAlertMessage" : this.writeAlertMessage, a.detectedMessage = void 0 === this.writeDetectedMessage ? "please set writeDetectedMessage" : this.writeDetectedMessage, a.recordData = void 0 === t ? "please set recordData" : t, a.recordId = void 0 === e ? "please set recordId" : e, window.natively.trigger(r, 15, i, "nfc_write", a) }, this.available = function (e) { window.natively.trigger(r, 15, e, "nfc_available", {}) } } } class NativelyAppleSignInService { constructor() { let e = generateID(); this.signin = function (t) { window.natively.trigger(e, 16, t, "apple_signin", {}) } } } function generateID() { return Date.now().toString(36) + Math.random().toString(36).substring(2) } export { NativelyAdmobBanner, NativelyAdmobInterstitial, NativelyAppleSignInService, NativelyAudioRecorder, NativelyBiometrics, NativelyCamera, NativelyClipboard, NativelyContacts, NativelyDatePicker, NativelyGeolocation, NativelyHealth, NativelyInfo, NativelyLocation, NativelyMediaPicker, NativelyMessage, NativelyNFCService, NativelyNotifications, NativelyPagesCache, NativelyPurchases, NativelyScanner, NativelyStorage };
@@ -93,14 +93,12 @@ window.natively = {
93
93
  $agent.trigger(method, body);
94
94
  },
95
95
 
96
- openLogger: function () {
96
+ openLogger: function () { // DEPRECATED after 2.14.0
97
97
  $agent.natively_logger();
98
98
  },
99
99
 
100
- // Not available right now
101
100
  openConsole: function () {
102
- window.natively.trigger(undefined, 30, undefined, "app_console");
103
-
101
+ window.natively.trigger(undefined, 22, undefined, "app_console");
104
102
  },
105
103
 
106
104
  closeApp: function () {
@@ -144,35 +142,60 @@ window.natively = {
144
142
  window.natively.trigger(undefined, 18, undefined, "open_link", params);
145
143
  },
146
144
 
147
- openExternalAppIOS(url) {
145
+ openExternalAppIOS(url) { // DEPRECATED after 2.14.0
148
146
  window.natively.trigger(undefined, 0, undefined, "open_app", {
149
147
  url,
150
148
  });
151
149
  },
152
150
 
151
+ openExternalApp(url) {
152
+ window.natively.trigger(undefined, 22, undefined, "open_app", {
153
+ url,
154
+ });
155
+ },
156
+
153
157
  openAppSettings() {
154
158
  window.natively.trigger(undefined, 0, undefined, "open_appsettings");
155
159
  },
156
160
 
157
- hapticPatternIOS(pattern, delay) {
161
+ hapticPatternIOS(pattern, delay) { // DEPRECATED after 2.14.0
158
162
  window.natively.trigger(undefined, 7, undefined, "haptic_pattern", {
159
163
  pattern,
160
164
  delay
161
165
  });
162
166
  },
163
167
 
164
- hapticImpactIOS(type) {
168
+ hapticImpactIOS(type) { // DEPRECATED after 2.14.0
165
169
  window.natively.trigger(undefined, 7, undefined, "haptic_impact", {
166
170
  type,
167
171
  });
168
172
  },
169
173
 
170
- hapticNotificationIOS(type) {
174
+ hapticNotificationIOS(type) { // DEPRECATED after 2.14.0
171
175
  window.natively.trigger(undefined, 7, undefined, "haptic_notification", {
172
176
  type,
173
177
  });
174
178
  },
175
179
 
180
+ hapticPattern(pattern, delay) {
181
+ window.natively.trigger(undefined, 22, undefined, "haptic_pattern", {
182
+ pattern,
183
+ delay
184
+ });
185
+ },
186
+
187
+ hapticImpact(type) {
188
+ window.natively.trigger(undefined, 22, undefined, "haptic_impact", {
189
+ type,
190
+ });
191
+ },
192
+
193
+ hapticNotification(type) {
194
+ window.natively.trigger(undefined, 22, undefined, "haptic_notification", {
195
+ type,
196
+ });
197
+ },
198
+
176
199
  showAppToast(type, text) {
177
200
  const params = {};
178
201
  params.text = typeof text === "undefined" ? "" : text;
@@ -202,11 +225,16 @@ window.natively = {
202
225
  window.natively.trigger(undefined, 1, undefined, "app_progress", params);
203
226
  },
204
227
 
205
- setAppSwipeNavigationIOS(toggle) {
228
+ setAppSwipeNavigationIOS(toggle) { // DEPRECATED after 2.14.0
206
229
  const params = { toggle };
207
230
  window.natively.trigger(undefined, 1, undefined, "app_navigation", params);
208
231
  },
209
232
 
233
+ setAppSwipeNavigation(toggle) {
234
+ const params = { toggle };
235
+ window.natively.trigger(undefined, 22, undefined, "app_navigation", params);
236
+ },
237
+
210
238
  setAppPullToRefresh(toggle) {
211
239
  const params = { toggle };
212
240
  window.natively.trigger(undefined, 1, undefined, "app_pull", params);
@@ -217,7 +245,7 @@ window.natively = {
217
245
  window.natively.trigger(undefined, 3, undefined, "app_orientation", params);
218
246
  },
219
247
 
220
- setAppStatusBarStyleIOS(style) {
248
+ setAppStatusBarStyleIOS(style) { // DEPRECATED after 2.14.0
221
249
  const params = { style };
222
250
  window.natively.trigger(
223
251
  undefined,
@@ -228,6 +256,17 @@ window.natively = {
228
256
  );
229
257
  },
230
258
 
259
+ setAppStatusBarStyle(style) {
260
+ const params = { style };
261
+ window.natively.trigger(
262
+ undefined,
263
+ 22,
264
+ undefined,
265
+ "status_bar_style",
266
+ params
267
+ );
268
+ },
269
+
231
270
  hideLoadingScreen() {
232
271
  const show_loader = false;
233
272
  const auto_hide = true;
@@ -790,14 +829,7 @@ class NativelyAudioRecorder {
790
829
  // Make sure to use this an not reload page a lot
791
830
  class NativelyAdmobBanner {
792
831
  constructor(
793
- config = {
794
- iOSUnitId: "ca-app-pub-3940256099942544/2934735716",
795
- androidUnitId: "ca-app-pub-3940256099942544/6300978111",
796
- position: "BOTTOM",
797
- sizeType: "AUTO",
798
- custom_width: 320,
799
- custom_height: 50
800
- },
832
+ config,
801
833
  setup_callback = undefined, // function(resp) { console.log(resp) }
802
834
  preload_ad = false, // Load ad on init
803
835
  preload_callback = undefined, // function(resp) { console.log(resp) }
@@ -805,7 +837,7 @@ class NativelyAdmobBanner {
805
837
  show_callback = undefined, // function(resp) { console.log(resp) }
806
838
  ) {
807
839
  const id = generateID();
808
- const params = {};
840
+ let params = {};
809
841
  if (window.natively.isAndroidApp) {
810
842
  params.unitId = (typeof config.androidUnitId === "undefined") ? "ca-app-pub-3940256099942544/6300978111" : config.androidUnitId;
811
843
  } else if (window.natively.isIOSApp) {
@@ -814,8 +846,8 @@ class NativelyAdmobBanner {
814
846
 
815
847
  params.position = (typeof config.position === "undefined") ? "BOTTOM" : config.position;
816
848
  params.sizeType = (typeof config.sizeType === "undefined") ? "AUTO" : config.sizeType;
817
- params.width = (typeof config.custom_width === "undefined") ? 320 : config.width;
818
- params.height = (typeof config.custom_height === "undefined") ? 50 : config.height;
849
+ params.width = (typeof config.custom_width === "undefined") ? 320 : config.custom_width;
850
+ params.height = (typeof config.custom_height === "undefined") ? 50 : config.custom_height;
819
851
  window.natively.trigger(id, 14, function (resp) {
820
852
  if (typeof setup_callback !== "undefined") {
821
853
  setup_callback(resp);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "natively",
3
- "version": "2.13.2",
3
+ "version": "2.14.0",
4
4
  "description": "",
5
5
  "main": "natively-frontend.min.mjs",
6
6
  "type": "module",