natively 2.2.2 → 2.3.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.
- package/natively-frontend.js +19 -0
- package/natively-frontend.min.js +1 -1
- package/package.json +1 -1
package/natively-frontend.js
CHANGED
|
@@ -132,6 +132,25 @@ window.natively = {
|
|
|
132
132
|
window.natively.trigger(undefined, 0, undefined, "open_appsettings");
|
|
133
133
|
},
|
|
134
134
|
|
|
135
|
+
hapticPatternIOS(pattern, delay) {
|
|
136
|
+
window.natively.trigger(undefined, 7, undefined, "haptic_pattern", {
|
|
137
|
+
pattern,
|
|
138
|
+
delay
|
|
139
|
+
});
|
|
140
|
+
},
|
|
141
|
+
|
|
142
|
+
hapticImpactIOS(type) {
|
|
143
|
+
window.natively.trigger(undefined, 7, undefined, "haptic_impact", {
|
|
144
|
+
type,
|
|
145
|
+
});
|
|
146
|
+
},
|
|
147
|
+
|
|
148
|
+
hapticNotificationIOS(type) {
|
|
149
|
+
window.natively.trigger(undefined, 7, undefined, "haptic_notification", {
|
|
150
|
+
type,
|
|
151
|
+
});
|
|
152
|
+
},
|
|
153
|
+
|
|
135
154
|
showAppToast(type, text) {
|
|
136
155
|
const params = {};
|
|
137
156
|
params.text = typeof text === "undefined" ? "" : text;
|
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:[],setDebug:function(
|
|
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:[],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&&console.log("[INFO] Notify observers: ",e.length);e.length>0;){const i=e.shift();i()}},addObserver:function(i){window.natively.injected?i():(window.natively.isDebug&&console.log(`[DEBUG] addObserver: ${i}`),window.natively.observers.push(i))},trigger:function(i,t,e,n,o){const r=window.natively.isDebug;if(window.natively.injected)if(t>window.natively.app_version)r&&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(n,o){$agent.response(),o.message&&r?alert(`[ERROR] Error message: ${o.message}`):(r&&console.log(`[DEBUG] Callback method: ${t}, body: ${JSON.stringify(n)}, respId: ${i}`),e(n))},o?o.response_id=i:o={response_id:i}}r&&console.log(`[DEBUG] Trigger method: ${n}, body: ${JSON.stringify(o)}`),$agent.trigger(n,o)}else window.natively.addObserver(()=>{window.natively.trigger(i,t,e,n,o)})},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){window.natively.trigger(void 0,0,void 0,"open_link",{url:i})},openExternalAppIOS(i){window.natively.trigger(void 0,0,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})},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)},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)},async sendPushNotification(i,t,e,n){const o=e.filter(i=>i.length>0),r=[...new Set(o)];let s={app_id:n?"be83022a-1d08-45d0-a07a-0c3655666e17":i,include_player_ids:r};t.template_id?s.template_id=t.template_id:(s.headings={},s.headings.en=t.title||"Empty Title",s.contents={},s.contents.en=t.message||"Empty Message",t.subtitle&&(s.subtitle={},s.subtitle.en=t.subtitle),t.redirect_url&&(s.url=t.redirect_url));const a={method:"POST",headers:{"Content-type":"application/json"},body:JSON.stringify(s)};return await fetch("https://onesignal.com/api/v1/notifications",a)}},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(){const i="undefined"!=typeof $agent,t=window.navigator.userAgent.includes("Natively/iOS"),e=window.navigator.userAgent.includes("Natively/Android");return{isNativeApp:i,isIOSApp:t,isAndroidApp:e}},this.getAppInfo=function(t){window.natively.trigger(i,0,t,"app_info")},this.connectivity=function(i){window.natively.trigger(void 0,0,i,"connectivity")}}}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){window.natively.trigger(i,3,n,"location_current",{accuracy:t,priority:e})},this.permission=function(t){window.natively.trigger(i,6,t,"location_permission")},this.start=function(t,e,n,o){window.natively.trigger(i,3,o,"location_start",{accuracy:e,priority:n,interval:t})},this.stop=function(){window.natively.trigger(i,3,void 0,"location_stop",{})},this.startBackground=function(t,e,n,o,r){const s={};s.identifier=void 0===o?"empty":o,s.interval=void 0===t?6e4:t,s.accuracy=void 0===e?50:e,s.priority=void 0===n?"BALANCED":n,window.natively.trigger(i,4,r,"location_start_bg",s)},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 r={};r.subject=void 0===t?"":t,r.body=void 0===e?"":e,r.recipient=void 0===n?"":n,window.natively.trigger(i,0,o,"send_email",r)}}}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,r){let s={};s.type=void 0===n?"DATE":n,s.style=void 0===o?"LIGHT":o,s.title=void 0===t?"":t,s.description=void 0===e?"":e,window.natively.trigger(i,0,r,"datepicker",s)}}}class NativelyCamera{constructor(){const i=generateID();this.showCamera=function(t,e,n,o){let r={};r.type=void 0===t?"photo":t,r.quality=void 0===e?"high":e,r.camera=void 0===n?"BACK":n,window.natively.trigger(i,2,o,"open_camera",r)}}}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){window.natively.trigger(i,3,e,"purchases_login",{login:t})},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.purchasePackage=function(t,e){window.natively.trigger(i,3,e,"purchases_package",{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,r){let s={firstName:t};s.lastName=void 0===e?"":e,s.email=void 0===n?"":n,s.phone=void 0===o?"":o,window.natively.trigger(i,3,r,"contacts_save",s)}}}
|