natively 2.12.1 → 2.12.3
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.
- package/natively-frontend.js +37 -29
- package/natively-frontend.min.js +1 -1
- package/package.json +1 -1
package/natively-frontend.js
CHANGED
|
@@ -133,8 +133,8 @@ window.natively = {
|
|
|
133
133
|
openExternalURL(url, external) {
|
|
134
134
|
const params = {};
|
|
135
135
|
params.url = typeof url === "undefined" ? "https://buildnatively.com" : url;
|
|
136
|
-
const
|
|
137
|
-
params.view =
|
|
136
|
+
const isExternal = typeof external === "undefined" ? false : external;
|
|
137
|
+
params.view = isExternal ? "external" : "web";
|
|
138
138
|
window.natively.trigger(undefined, 18, undefined, "open_link", params);
|
|
139
139
|
},
|
|
140
140
|
|
|
@@ -254,7 +254,7 @@ window.natively = {
|
|
|
254
254
|
let notification = {
|
|
255
255
|
app_id: isPreview
|
|
256
256
|
? // Natively Preview App ID
|
|
257
|
-
|
|
257
|
+
"be83022a-1d08-45d0-a07a-0c3655666e17"
|
|
258
258
|
: appId,
|
|
259
259
|
include_player_ids,
|
|
260
260
|
};
|
|
@@ -317,6 +317,11 @@ class NativelyInfo {
|
|
|
317
317
|
"connectivity"
|
|
318
318
|
);
|
|
319
319
|
};
|
|
320
|
+
// app_state_callback responsible for app state changes.
|
|
321
|
+
// e.g. app is in background or foreground (available >= 2.12.2)
|
|
322
|
+
this.app_state = function (app_state_callback) {
|
|
323
|
+
window.natively.trigger(undefined, 19, app_state_callback, "app_state");
|
|
324
|
+
};
|
|
320
325
|
}
|
|
321
326
|
}
|
|
322
327
|
|
|
@@ -442,6 +447,9 @@ class NativelyLocation {
|
|
|
442
447
|
params.priority = typeof priority_android === "undefined" ? "BALANCED" : priority_android;
|
|
443
448
|
window.natively.trigger(id, 12, location_bg_callback, "location_start_bg", params);
|
|
444
449
|
};
|
|
450
|
+
this.statusBackground = function (location_bg_status_callback) {
|
|
451
|
+
window.natively.trigger(id, 20, location_bg_status_callback, "location_status_bg", {});
|
|
452
|
+
}
|
|
445
453
|
this.stopBackground = function (location_bg_callback) {
|
|
446
454
|
window.natively.trigger(id, 4, location_bg_callback, "location_stop_bg", {});
|
|
447
455
|
};
|
|
@@ -766,13 +774,13 @@ class NativelyAudioRecorder {
|
|
|
766
774
|
// Make sure to use this an not reload page a lot
|
|
767
775
|
class NativelyAdmobBanner {
|
|
768
776
|
constructor(
|
|
769
|
-
config = {
|
|
777
|
+
config = {
|
|
770
778
|
iOSUnitId: "ca-app-pub-3940256099942544/2934735716",
|
|
771
779
|
androidUnitId: "ca-app-pub-3940256099942544/6300978111",
|
|
772
|
-
position: "BOTTOM",
|
|
773
|
-
sizeType: "AUTO",
|
|
774
|
-
custom_width: 320,
|
|
775
|
-
custom_height: 50
|
|
780
|
+
position: "BOTTOM",
|
|
781
|
+
sizeType: "AUTO",
|
|
782
|
+
custom_width: 320,
|
|
783
|
+
custom_height: 50
|
|
776
784
|
},
|
|
777
785
|
setup_callback = undefined, // function(resp) { console.log(resp) }
|
|
778
786
|
preload_ad = false, // Load ad on init
|
|
@@ -787,25 +795,25 @@ class NativelyAdmobBanner {
|
|
|
787
795
|
} else if (window.natively.isIOSApp) {
|
|
788
796
|
params.unitId = (typeof config.iOSUnitId === "undefined") ? "ca-app-pub-3940256099942544/2934735716" : config.iOSUnitId;
|
|
789
797
|
}
|
|
790
|
-
|
|
798
|
+
|
|
791
799
|
params.position = (typeof config.position === "undefined") ? "BOTTOM" : config.position;
|
|
792
800
|
params.sizeType = (typeof config.sizeType === "undefined") ? "AUTO" : config.sizeType;
|
|
793
801
|
params.width = (typeof config.custom_width === "undefined") ? 320 : config.width;
|
|
794
802
|
params.height = (typeof config.custom_height === "undefined") ? 50 : config.height;
|
|
795
|
-
window.natively.trigger(id, 14, function(resp) {
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
803
|
+
window.natively.trigger(id, 14, function (resp) {
|
|
804
|
+
if (typeof setup_callback !== "undefined") {
|
|
805
|
+
setup_callback(resp);
|
|
806
|
+
}
|
|
807
|
+
if (preload_ad) {
|
|
808
|
+
window.natively.trigger(id, 14, function (resp) {
|
|
809
|
+
if (typeof preload_callback !== "undefined") {
|
|
810
|
+
preload_callback(resp);
|
|
811
|
+
}
|
|
812
|
+
if (show_ad) {
|
|
813
|
+
window.natively.trigger(id, 14, show_callback, "bannerad_show", {});
|
|
814
|
+
}
|
|
815
|
+
}, "bannerad_load", {});
|
|
816
|
+
}
|
|
809
817
|
}, "bannerad_setup", params);
|
|
810
818
|
|
|
811
819
|
this.loadAd = function (callback) {
|
|
@@ -844,20 +852,20 @@ class NativelyAdmobInterstitial {
|
|
|
844
852
|
} else if (window.natively.isIOSApp) {
|
|
845
853
|
unitId = (typeof iOSUnitId === "undefined") ? "ca-app-pub-3940256099942544/4411468910" : iOSUnitId;
|
|
846
854
|
}
|
|
847
|
-
|
|
855
|
+
|
|
848
856
|
this.loadAd = function (callback) {
|
|
849
857
|
const params = {};
|
|
850
858
|
params.unitId = (typeof unitId === "undefined") ? "ca-app-pub-3940256099942544/4411468910" : unitId;
|
|
851
859
|
window.natively.trigger(id, 14, callback, "interstitialad_setup", params);
|
|
852
860
|
};
|
|
853
861
|
this.showInterstitialAd = function (callback) {
|
|
854
|
-
window.natively.trigger(id, 14, function(resp) {
|
|
862
|
+
window.natively.trigger(id, 14, function (resp) {
|
|
855
863
|
callback(resp);
|
|
856
864
|
if (resp.event === "DID_DISMISS_AD" && auto_ad_reload) {
|
|
857
865
|
const params = {};
|
|
858
866
|
params.unitId = unitId;
|
|
859
867
|
setTimeout(() => {
|
|
860
|
-
window.natively.trigger(id, 14, auto_ad_reload_callback, "interstitialad_setup", params);
|
|
868
|
+
window.natively.trigger(id, 14, auto_ad_reload_callback, "interstitialad_setup", params);
|
|
861
869
|
}, 500);
|
|
862
870
|
}
|
|
863
871
|
}, "interstitialad_show", {});
|
|
@@ -872,9 +880,9 @@ class NativelyAdmobInterstitial {
|
|
|
872
880
|
// >=2.10.0
|
|
873
881
|
class NativelyNFCService {
|
|
874
882
|
constructor(
|
|
875
|
-
readAlertMessage,
|
|
876
|
-
writeAlertMessage,
|
|
877
|
-
readDetectedMessage,
|
|
883
|
+
readAlertMessage,
|
|
884
|
+
writeAlertMessage,
|
|
885
|
+
readDetectedMessage,
|
|
878
886
|
writeDetectedMessage
|
|
879
887
|
) {
|
|
880
888
|
const id = generateID();
|
package/natively-frontend.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function generateID(){return Date.now().toString(36)+Math.random().toString(36).substring(2)}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,i){window.natively.injected=!0,e&&(window.natively.min_app_version=e),i&&(window.natively.app_version=i);const t=window.natively.observers;for(natively.isDebug&&console.log("[INFO] Notify observers: ",t.length);t.length>0;){const e=t.shift();e()}},addObserver:function(e){window.natively.injected?e():(window.natively.isDebug&&console.log(`[DEBUG] addObserver: ${e}`),window.natively.observers.push(e))},trigger:function(e,i,t,n,o){const a=window.natively.isDebug;if(window.natively.injected)if(i>window.natively.app_version)a&&alert(`[ERROR] Please rebuild the app to use this functionality. App Version: ${window.natively.app_version}, feature version: ${i}`);else{if(t){let i;i=e?n+"_response_"+e:n+"_response",window[i]=function(n,o){$agent.response(),o.message&&a?alert(`[ERROR] Error message: ${o.message}`):(a&&console.log(`[DEBUG] Callback method: ${i}, body: ${JSON.stringify(n)}, respId: ${e}`),t(n))},o?o.response_id=e:o={response_id:e}}a&&console.log(`[DEBUG] Trigger method: ${n}, body: ${JSON.stringify(o)}`),$agent.trigger(n,o)}else window.natively.addObserver(()=>{window.natively.trigger(e,i,t,n,o)})},openLogger:function(){$agent.natively_logger()},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,i){window.natively.trigger(void 0,0,void 0,"share_text_and_image",{url:i,text:e})},shareFile(e){window.natively.trigger(void 0,2,void 0,"share_file",{url:e})},openExternalURL(e){window.natively.trigger(void 0,0,void 0,"open_link",{url:e})},openExternalAppIOS(e){window.natively.trigger(void 0,0,void 0,"open_app",{url:e})},openAppSettings(){window.natively.trigger(void 0,0,void 0,"open_appsettings")},hapticPatternIOS(e,i){window.natively.trigger(void 0,7,void 0,"haptic_pattern",{pattern:e,delay:i})},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})},showAppToast(e,i){const t={};t.text=void 0===i?"":i,t.type=void 0===e?"DEFAULT":e,window.natively.trigger(void 0,0,void 0,"show_toast",t)},showAppBanner(e,i,t){const n={};n.type=void 0===e?"INFO":e,n.title=void 0===i?"":i,n.description=void 0===t?"":t,window.natively.trigger(void 0,0,void 0,"show_banner",n)},requestAppReview(){window.natively.trigger(void 0,0,void 0,"request_review")},setAppBackgroundColor(e){const i={color:e};window.natively.trigger(void 0,1,void 0,"app_background",i)},setAppProgressColor(e){const i={color:e};window.natively.trigger(void 0,1,void 0,"app_progress",i)},setAppSwipeNavigationIOS(e){const i={toggle:e};window.natively.trigger(void 0,1,void 0,"app_navigation",i)},setAppPullToRefresh(e){const i={toggle:e};window.natively.trigger(void 0,1,void 0,"app_pull",i)},setAppOrientation(e){const i={orientation:e};window.natively.trigger(void 0,3,void 0,"app_orientation",i)},setAppStatusBarStyleIOS(e){const i={style:e};window.natively.trigger(void 0,2,void 0,"status_bar_style",i)},hideLoadingScreen(){const e=!1,i=!0,t={show_loader:e,auto_hide:i};window.natively.trigger(void 0,17,void 0,"loading_screen",t)},showLoadingScreen(e){const i=!0,t=void 0!==e&&e,n={show_loader:i,auto_hide:t};window.natively.trigger(void 0,17,void 0,"loading_screen",n)},async sendPushNotification(e,i,t,n){const o=t.filter(e=>e.length>0),a=[...new Set(o)];let r={app_id:n?"be83022a-1d08-45d0-a07a-0c3655666e17":e,include_player_ids:a};i.template_id?r.template_id=i.template_id:(r.headings={},r.headings.en=i.title||"Empty Title",r.contents={},r.contents.en=i.message||"Empty Message",i.subtitle&&(r.subtitle={},r.subtitle.en=i.subtitle),i.redirect_url&&(r.url=i.redirect_url));const s={method:"POST",headers:{"Content-type":"application/json"},body:JSON.stringify(r)};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(){const e=generateID();this.browserInfo=function(){const e="undefined"!=typeof $agent,i=window.navigator.userAgent.includes("Natively/iOS"),t=window.navigator.userAgent.includes("Natively/Android");return{isNativeApp:e,isIOSApp:i,isAndroidApp:t}},this.getAppInfo=function(i){window.natively.trigger(e,0,i,"app_info")},this.connectivity=function(e){window.natively.trigger(void 0,0,e,"connectivity")}}}class NativelyClipboard{constructor(){const e=generateID();this.copy=function(e){window.natively.trigger(void 0,11,void 0,"clipboard_copy",{text:e})},this.paste=function(i){window.natively.trigger(e,11,i,"clipboard_paste")}}}class NativelyPagesCache{constructor(){const e=generateID();this.currentPageCached=function(i){window.natively.trigger(e,4,i,"current_page_cached")},this.storeCurrentPage=function(i){window.natively.trigger(e,4,i,"store_current_page")},this.resetCurrentPage=function(i){window.natively.trigger(e,4,i,"reset_current_page")},this.resetAll=function(i){window.natively.trigger(e,4,i,"reset_all")}}}class NativelyNotifications{constructor(){const e=generateID();this.getOneSignalId=function(i){window.natively.trigger(e,0,i,"onesignal_playerid")},this.requestPermission=function(i,t){window.natively.trigger(e,0,t,"push_register",{fallbackToSettings:i})},this.getPermissionStatus=function(i){window.natively.trigger(e,0,i,"push_permission")}}}class NativelyGeolocation{constructor(){const e=generateID();this.getUserGeolocation=function(i,t){window.natively.trigger(e,0,t,"geolocation",{distance:i})},this.requestPermission=function(i){window.natively.trigger(e,0,i,"geo_register")},this.getPermissionStatus=function(i){window.natively.trigger(e,0,i,"geo_permission")}}}class NativelyLocation{constructor(){const e=generateID();this.current=function(i,t,n,o){window.natively.trigger(e,12,o,"location_current",{minAccuracy:i,accuracyType:t,priority:n})},this.permission=function(i){window.natively.trigger(e,6,i,"location_permission")},this.start=function(i,t,n,o,a){window.natively.trigger(e,12,a,"location_start",{minAccuracy:t,accuracyType:n,priority:o,interval:i})},this.stop=function(){window.natively.trigger(e,3,void 0,"location_stop",{})},this.startBackground=function(i,t,n,o,a,r){const s={};s.identifier=void 0===a?"empty":a,s.interval=void 0===i?6e4:i,s.minAccuracy=void 0===t?50:t,s.accuracyType=void 0===n?"Best":n,s.priority=void 0===o?"BALANCED":o,window.natively.trigger(e,12,r,"location_start_bg",s)},this.stopBackground=function(i){window.natively.trigger(e,4,i,"location_stop_bg",{})}}}class NativelyMessage{constructor(){const e=generateID();this.sendSMS=function(i,t,n){const o={};o.body=void 0===i?"":i,o.recipient=void 0===t?"":t,window.natively.trigger(e,0,n,"send_sms",o)},this.sendEmail=function(i,t,n,o){const a={};a.subject=void 0===i?"":i,a.body=void 0===t?"":t,a.recipient=void 0===n?"":n,window.natively.trigger(e,0,o,"send_email",a)}}}class NativelyStorage{constructor(){const e=generateID();this.setStorageValue=function(i,t){window.natively.trigger(e,0,void 0,"set_storage_value",{key:i,value:t})},this.getStorageValue=function(i,t){window.natively.trigger(e,0,t,"get_storage_value",{key:i})},this.removeStorageValue=function(i){window.natively.trigger(e,0,void 0,"remove_storage_value",{key:i})},this.resetStorage=function(){window.natively.trigger(e,0,void 0,"reset_storage")}}}class NativelyBiometrics{constructor(e){this.allowPass=e;const i=generateID();this.checkBiometricsSupport=function(t){window.natively.trigger(i,0,t,"biometrics_support",{allowPass:e})},this.checkCredentials=function(e){window.natively.trigger(i,0,e,"biometrics_has_credentials")},this.verifyUserIdentify=function(t){window.natively.trigger(i,0,t,"biometrics_verify",{allowPass:e})},this.getUserCredentials=function(t){window.natively.trigger(i,0,t,"biometrics_auth",{allowPass:e})},this.removeUserCredentials=function(e){window.natively.trigger(i,0,e,"biometrics_remove_credentials")},this.saveUserCredentials=function(t,n,o){window.natively.trigger(i,0,o,"biometrics_auth",{allowPass:e,login:t,password:n})}}}class NativelyDatePicker{constructor(){const e=generateID();this.showDatePicker=function(i,t,n,o,a){let r={};r.type=void 0===n?"DATE":n,r.style=void 0===o?"LIGHT":o,r.title=void 0===i?"":i,r.description=void 0===t?"":t,window.natively.trigger(e,0,a,"datepicker",r)}}}class NativelyCamera{constructor(){const e=generateID();this.showCamera=function(i,t,n,o){let a={};a.type=void 0===i?"photo":i,a.quality=void 0===t?"high":t,a.camera=void 0===n?"BACK":n,window.natively.trigger(e,2,o,"open_camera",a)}}}class NativelyHealth{constructor(){const e=generateID();this.available=function(i){window.natively.trigger(e,10,i,"health_available",{})},this.requestAuthorization=function(i,t,n){window.natively.trigger(e,10,n,"health_register",{write_data_types:i,read_data_types:t})},this.permissionStatus=function(i,t){window.natively.trigger(e,10,t,"health_permission",{data_type:i})},this.getAllCharacteristics=function(i){window.natively.trigger(e,10,i,"health_get_all_characteristics",{})},this.getStatisticQuantity=function(i,t,n,o,a){const r={data_type:i,interval:t};void 0!==n&&(r.start_date=n.getTime()),void 0!==o&&(r.end_date=o.getTime()),window.natively.trigger(e,10,a,"health_get_statistic_quantity",r)},this.getDailySleepAnalysis=function(i,t,n,o){const a={limit:n||100};void 0!==i&&(a.start_date=i.getTime()),void 0!==t&&(a.end_date=t.getTime()),window.natively.trigger(e,10,o,"health_get_daily_sleep_analysis",a)},this.getActivitySummary=function(i,t,n){const o={};void 0!==i&&(o.start_date=i.getTime()),void 0!==t&&(o.end_date=t.getTime()),window.natively.trigger(e,10,n,"health_get_activity_summary",o)}}}class NativelyScanner{constructor(){const e=generateID();this.showScanner=function(i){window.natively.trigger(e,2,i,"open_scanner",{})}}}class NativelyPurchases{constructor(){const e=generateID();this.login=function(i,t,n){const o=void 0===t?"":t;window.natively.trigger(e,3,n,"purchases_login",{login:i,email:o})},this.logout=function(i){window.natively.trigger(e,3,i,"purchases_logout",{})},this.customerId=function(i){window.natively.trigger(e,3,i,"purchases_customerid",{})},this.restore=function(i){window.natively.trigger(e,10,i,"purchases_restore",{})},this.purchasePackage=function(i,t){window.natively.trigger(e,3,t,"purchases_package",{packageId:i})},this.packagePrice=function(i,t){window.natively.trigger(e,8,t,"purchases_price",{packageId:i})}}}class NativelyContacts{constructor(){const e=generateID();this.getAllContacts=function(i){window.natively.trigger(e,3,i,"contacts_all",{})},this.createContact=function(i,t,n,o,a){let r={firstName:i};r.lastName=void 0===t?"":t,r.email=void 0===n?"":n,r.phone=void 0===o?"":o,window.natively.trigger(e,3,a,"contacts_save",r)}}}class NativelyMediaPicker{constructor(){const e=generateID();this.showMediaPicker=function(i){window.natively.trigger(e,8,i,"mediapicker",{})}}}class NativelyAudioRecorder{constructor(){const e=generateID();this.showRecorder=function(i,t){let n={};n.max_duration=void 0===i?0:i,window.natively.trigger(e,13,t,"record_start",n)}}}class NativelyAdmobBanner{constructor(e={iOSUnitId:"ca-app-pub-3940256099942544/2934735716",androidUnitId:"ca-app-pub-3940256099942544/6300978111",position:"BOTTOM",sizeType:"AUTO",custom_width:320,custom_height:50},i,t=!1,n,o=!1,a){const r=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.width,s.height=void 0===e.custom_height?50:e.height,window.natively.trigger(r,14,function(e){void 0!==i&&i(e),t&&window.natively.trigger(r,14,function(e){void 0!==n&&n(e),o&&window.natively.trigger(r,14,a,"bannerad_show",{})},"bannerad_load",{})},"bannerad_setup",s),this.loadAd=function(e){window.natively.trigger(r,14,e,"bannerad_load",{})},this.showBanner=function(e){window.natively.trigger(r,14,e,"bannerad_show",{})},this.hideBanner=function(e){window.natively.trigger(r,14,e,"bannerad_hide",{})},this.bannerIsReady=function(e){window.natively.trigger(r,14,e,"bannerad_ready",{})},this.bannerIsVisible=function(e){window.natively.trigger(r,14,e,"bannerad_visible",{})}}}class NativelyAdmobInterstitial{constructor(e="ca-app-pub-3940256099942544/4411468910",i="ca-app-pub-3940256099942544/1033173712",t,n=!1,o){const a=generateID();let r;window.natively.isAndroidApp?r=void 0===i?"ca-app-pub-3940256099942544/1033173712":i:window.natively.isIOSApp&&(r=void 0===e?"ca-app-pub-3940256099942544/4411468910":e),this.loadAd=function(e){const i={};i.unitId=void 0===r?"ca-app-pub-3940256099942544/4411468910":r,window.natively.trigger(a,14,e,"interstitialad_setup",i)},this.showInterstitialAd=function(e){window.natively.trigger(a,14,function(i){if(e(i),"DID_DISMISS_AD"===i.event&&n){const e={};e.unitId=r,setTimeout(()=>{window.natively.trigger(a,14,o,"interstitialad_setup",e)},500)}},"interstitialad_show",{})},this.interstitialIsReady=function(e){window.natively.trigger(a,14,e,"interstitialad_ready",{})},this.loadAd(t)}}class NativelyNFCService{constructor(e,i,t,n){const o=generateID();this.readAlertMessage=e,this.writeAlertMessage=i,this.readDetectedMessage=t,this.writeDetectedMessage=n,this.read=function(e){let i={};i.alertMessage=void 0===this.readAlertMessage?"please set readAlertMessage":this.readAlertMessage,i.detectedMessage=void 0===this.readDetectedMessage?"readDetectedMessage":this.readDetectedMessage,window.natively.trigger(o,15,e,"nfc_read",i)},this.write=function(e,i,t){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===i?"please set recordData":i,n.recordId=void 0===e?"please set recordId":e,window.natively.trigger(o,15,t,"nfc_write",n)},this.available=function(e){let i={};window.natively.trigger(o,15,e,"nfc_available",i)}}}class NativelyAppleSignInService{constructor(){const e=generateID();this.signin=function(i){let t={};window.natively.trigger(e,16,i,"apple_signin",t)}}}
|
|
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(isDebug){window.natively.isDebug=isDebug},notify:function(min,current){window.natively.injected=!0,min&&(window.natively.min_app_version=min),current&&(window.natively.app_version=current);const observers=window.natively.observers;for(natively.isDebug&&console.log("[INFO] Notify observers: ",observers.length);observers.length>0;){observers.shift()()}},addObserver:function(fn){window.natively.injected?fn():(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)if(minVersion>window.natively.app_version)isTestVersion&&alert(`[ERROR] Please rebuild the app to use this functionality. App Version: ${window.natively.app_version}, feature version: ${minVersion}`);else{if(callback){let fullMethodName;fullMethodName=respId?method+"_response_"+respId:method+"_response",window[fullMethodName]=function(resp,err){$agent.response(),err.message&&isTestVersion?alert(`[ERROR] Error message: ${err.message}`):(isTestVersion&&console.log(`[DEBUG] Callback method: ${fullMethodName}, body: ${JSON.stringify(resp)}, respId: ${respId}`),callback(resp))},body?body.response_id=respId:body={response_id:respId}}isTestVersion&&console.log(`[DEBUG] Trigger method: ${method}, body: ${JSON.stringify(body)}`),$agent.trigger(method,body)}else window.natively.addObserver((()=>{window.natively.trigger(respId,minVersion,callback,method,body)}))},openLogger:function(){$agent.natively_logger()},closeApp:function(){window.natively.trigger(void 0,11,void 0,"app_close")},showProgress:function(toggle){window.natively.trigger(void 0,11,void 0,"app_show_progress",{toggle:toggle})},shareImage(image_url){window.natively.trigger(void 0,0,void 0,"share_image",{url:image_url})},shareText(text){window.natively.trigger(void 0,0,void 0,"share_text",{text:text})},shareTextAndImage(text,image_url){window.natively.trigger(void 0,0,void 0,"share_text_and_image",{url:image_url,text:text})},shareFile(file_url){window.natively.trigger(void 0,2,void 0,"share_file",{url:file_url})},openExternalURL(url,external){const params={};params.url=void 0===url?"https://buildnatively.com":url;const isExternal=void 0!==external&&external;params.view=isExternal?"external":"web",window.natively.trigger(void 0,18,void 0,"open_link",params)},openExternalAppIOS(url){window.natively.trigger(void 0,0,void 0,"open_app",{url:url})},openAppSettings(){window.natively.trigger(void 0,0,void 0,"open_appsettings")},hapticPatternIOS(pattern,delay){window.natively.trigger(void 0,7,void 0,"haptic_pattern",{pattern:pattern,delay:delay})},hapticImpactIOS(type){window.natively.trigger(void 0,7,void 0,"haptic_impact",{type:type})},hapticNotificationIOS(type){window.natively.trigger(void 0,7,void 0,"haptic_notification",{type:type})},showAppToast(type,text){const params={};params.text=void 0===text?"":text,params.type=void 0===type?"DEFAULT":type,window.natively.trigger(void 0,0,void 0,"show_toast",params)},showAppBanner(type,title,description){const params={};params.type=void 0===type?"INFO":type,params.title=void 0===title?"":title,params.description=void 0===description?"":description,window.natively.trigger(void 0,0,void 0,"show_banner",params)},requestAppReview(){window.natively.trigger(void 0,0,void 0,"request_review")},setAppBackgroundColor(color){const params={color:color};window.natively.trigger(void 0,1,void 0,"app_background",params)},setAppProgressColor(color){const params={color:color};window.natively.trigger(void 0,1,void 0,"app_progress",params)},setAppSwipeNavigationIOS(toggle){const params={toggle:toggle};window.natively.trigger(void 0,1,void 0,"app_navigation",params)},setAppPullToRefresh(toggle){const params={toggle:toggle};window.natively.trigger(void 0,1,void 0,"app_pull",params)},setAppOrientation(orientation){const params={orientation:orientation};window.natively.trigger(void 0,3,void 0,"app_orientation",params)},setAppStatusBarStyleIOS(style){const params={style:style};window.natively.trigger(void 0,2,void 0,"status_bar_style",params)},hideLoadingScreen(){const params={show_loader:!1,auto_hide:!0};window.natively.trigger(void 0,17,void 0,"loading_screen",params)},showLoadingScreen(autoHide){const params={show_loader:!0,auto_hide:void 0!==autoHide&&autoHide};window.natively.trigger(void 0,17,void 0,"loading_screen",params)},async sendPushNotification(appId,payload,player_ids,isPreview){const filtered=player_ids.filter((id=>id.length>0));let notification={app_id:isPreview?"be83022a-1d08-45d0-a07a-0c3655666e17":appId,include_player_ids:[...new Set(filtered)]};payload.template_id?notification.template_id=payload.template_id:(notification.headings={},notification.headings.en=payload.title||"Empty Title",notification.contents={},notification.contents.en=payload.message||"Empty Message",payload.subtitle&&(notification.subtitle={},notification.subtitle.en=payload.subtitle),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(void 0,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(){return{isNativeApp:"undefined"!=typeof $agent,isIOSApp:window.navigator.userAgent.includes("Natively/iOS"),isAndroidApp:window.navigator.userAgent.includes("Natively/Android")}},this.getAppInfo=function(app_info_callback){window.natively.trigger(id,0,app_info_callback,"app_info")},this.connectivity=function(connectivity_callback){window.natively.trigger(void 0,0,connectivity_callback,"connectivity")},this.app_state=function(app_state_callback){window.natively.trigger(void 0,19,app_state_callback,"app_state")}}}class NativelyClipboard{constructor(){const id=generateID();this.copy=function(text){window.natively.trigger(void 0,11,void 0,"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,void 0,"location_stop",{})},this.startBackground=function(interval,minAccuracyIOS,accuracyTypeIOS,priority_android,responseIdentifier,location_bg_callback){const params={};params.identifier=void 0===responseIdentifier?"empty":responseIdentifier,params.interval=void 0===interval?6e4:interval,params.minAccuracy=void 0===minAccuracyIOS?50:minAccuracyIOS,params.accuracyType=void 0===accuracyTypeIOS?"Best":accuracyTypeIOS,params.priority=void 0===priority_android?"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=void 0===body?"":body,params.recipient=void 0===recipient?"":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=void 0===subject?"":subject,params.body=void 0===body?"":body,params.recipient=void 0===recipient?"":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,void 0,"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,void 0,"remove_storage_value",{key:key})},this.resetStorage=function(){window.natively.trigger(id,0,void 0,"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=void 0===type?"DATE":type,params.style=void 0===style?"LIGHT":style,params.title=void 0===title?"":title,params.description=void 0===description?"":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=void 0===type?"photo":type,params.quality=void 0===quality?"high":quality,params.camera=void 0===camera?"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};void 0!==start_date&&(obj.start_date=start_date.getTime()),void 0!==end_date&&(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};void 0!==start_date&&(obj.start_date=start_date.getTime()),void 0!==end_date&&(obj.end_date=end_date.getTime()),window.natively.trigger(id,10,callback,"health_get_daily_sleep_analysis",obj)},this.getActivitySummary=function(start_date,end_date,callback){const obj={};void 0!==start_date&&(obj.start_date=start_date.getTime()),void 0!==end_date&&(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=void 0===customerEmail?"":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=void 0===lastName?"":lastName,params.email=void 0===email?"":email,params.phone=void 0===phone?"":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=void 0===max_duration?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=void 0,preload_ad=!1,preload_callback=void 0,show_ad=!1,show_callback=void 0){const id=generateID(),params={};window.natively.isAndroidApp?params.unitId=void 0===config.androidUnitId?"ca-app-pub-3940256099942544/6300978111":config.androidUnitId:window.natively.isIOSApp&&(params.unitId=void 0===config.iOSUnitId?"ca-app-pub-3940256099942544/2934735716":config.iOSUnitId),params.position=void 0===config.position?"BOTTOM":config.position,params.sizeType=void 0===config.sizeType?"AUTO":config.sizeType,params.width=void 0===config.custom_width?320:config.width,params.height=void 0===config.custom_height?50:config.height,window.natively.trigger(id,14,(function(resp){void 0!==setup_callback&&setup_callback(resp),preload_ad&&window.natively.trigger(id,14,(function(resp){void 0!==preload_callback&&preload_callback(resp),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=void 0,auto_ad_reload=!1,auto_ad_reload_callback=void 0){const id=generateID();let unitId;window.natively.isAndroidApp?unitId=void 0===androidUnitId?"ca-app-pub-3940256099942544/1033173712":androidUnitId:window.natively.isIOSApp&&(unitId=void 0===iOSUnitId?"ca-app-pub-3940256099942544/4411468910":iOSUnitId),this.loadAd=function(callback){const params={};params.unitId=void 0===unitId?"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){if(callback(resp),"DID_DISMISS_AD"===resp.event&&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=void 0===this.readAlertMessage?"please set readAlertMessage":this.readAlertMessage,params.detectedMessage=void 0===this.readDetectedMessage?"readDetectedMessage":this.readDetectedMessage,window.natively.trigger(id,15,callback,"nfc_read",params)},this.write=function(recordId,recordData,callback){let params={};params.alertMessage=void 0===this.writeAlertMessage?"please set writeAlertMessage":this.writeAlertMessage,params.detectedMessage=void 0===this.writeDetectedMessage?"please set writeDetectedMessage":this.writeDetectedMessage,params.recordData=void 0===recordData?"please set recordData":recordData,params.recordId=void 0===recordId?"please set recordId":recordId,window.natively.trigger(id,15,callback,"nfc_write",params)},this.available=function(callback){window.natively.trigger(id,15,callback,"nfc_available",{})}}}class NativelyAppleSignInService{constructor(){const id=generateID();this.signin=function(callback){window.natively.trigger(id,16,callback,"apple_signin",{})}}}function generateID(){return Date.now().toString(36)+Math.random().toString(36).substring(2)}
|