natively 2.2.0 → 2.2.2
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 +9 -2
- package/natively-frontend.min.js +1 -1
- package/package.json +1 -1
package/natively-frontend.js
CHANGED
|
@@ -240,7 +240,7 @@ class NativelyInfo {
|
|
|
240
240
|
constructor() {
|
|
241
241
|
const id = generateID();
|
|
242
242
|
this.browserInfo = function () {
|
|
243
|
-
const isNativeApp = typeof $agent !== undefined;
|
|
243
|
+
const isNativeApp = typeof $agent !== "undefined";
|
|
244
244
|
const isIOSApp = window.navigator.userAgent.includes("Natively/iOS");
|
|
245
245
|
const isAndroidApp = window.navigator.userAgent.includes("Natively/Android");
|
|
246
246
|
return { isNativeApp, isIOSApp, isAndroidApp };
|
|
@@ -337,6 +337,12 @@ class NativelyLocation {
|
|
|
337
337
|
priority: priority_android
|
|
338
338
|
});
|
|
339
339
|
};
|
|
340
|
+
// "AWLAYS" - background
|
|
341
|
+
// "IN_USE" - foreground
|
|
342
|
+
// "DENIED" - not determined or denied
|
|
343
|
+
this.permission = function (location_permission_callback) {
|
|
344
|
+
window.natively.trigger(id, 6, location_permission_callback, "location_permission");
|
|
345
|
+
};
|
|
340
346
|
this.start = function (interval, accuracy_ios, priority_android, location_callback) {
|
|
341
347
|
window.natively.trigger(id, 3, location_callback, "location_start", {
|
|
342
348
|
accuracy: accuracy_ios,
|
|
@@ -501,10 +507,11 @@ class NativelyDatePicker {
|
|
|
501
507
|
class NativelyCamera {
|
|
502
508
|
constructor() {
|
|
503
509
|
const id = generateID();
|
|
504
|
-
this.showCamera = function (type, quality, open_camera_callback) {
|
|
510
|
+
this.showCamera = function (type, quality, camera, open_camera_callback) {
|
|
505
511
|
let params = {};
|
|
506
512
|
params.type = typeof type === "undefined" ? "photo" : type;
|
|
507
513
|
params.quality = typeof quality === "undefined" ? "high" : quality;
|
|
514
|
+
params.camera = typeof camera === "undefined" ? "BACK" : camera;
|
|
508
515
|
window.natively.trigger(
|
|
509
516
|
id,
|
|
510
517
|
2,
|
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(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 r=window.natively.isDebug;if(window.natively.injected)if(i>window.natively.app_version)r&&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&&r?alert(`[ERROR] Error message: ${o.message}`):(r&&console.log(`[DEBUG] Callback method: ${i}, body: ${JSON.stringify(n)}, respId: ${e}`),t(n))},o?o.response_id=e:o={response_id:e}}r&&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)})},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")},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)},async sendPushNotification(e,i,t,n){const o=t.filter(e=>e.length>0),r=[...new Set(o)];let s={app_id:n?"be83022a-1d08-45d0-a07a-0c3655666e17":e,include_player_ids:r};i.template_id?s.template_id=i.template_id:(s.headings={},s.headings.en=i.title||"Empty Title",s.contents={},s.contents.en=i.message||"Empty Message",i.subtitle&&(s.subtitle={},s.subtitle.en=i.subtitle),i.redirect_url&&(s.url=i.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,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=
|
|
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(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 r=window.natively.isDebug;if(window.natively.injected)if(i>window.natively.app_version)r&&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&&r?alert(`[ERROR] Error message: ${o.message}`):(r&&console.log(`[DEBUG] Callback method: ${i}, body: ${JSON.stringify(n)}, respId: ${e}`),t(n))},o?o.response_id=e:o={response_id:e}}r&&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)})},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")},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)},async sendPushNotification(e,i,t,n){const o=t.filter(e=>e.length>0),r=[...new Set(o)];let s={app_id:n?"be83022a-1d08-45d0-a07a-0c3655666e17":e,include_player_ids:r};i.template_id?s.template_id=i.template_id:(s.headings={},s.headings.en=i.title||"Empty Title",s.contents={},s.contents.en=i.message||"Empty Message",i.subtitle&&(s.subtitle={},s.subtitle.en=i.subtitle),i.redirect_url&&(s.url=i.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,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 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){window.natively.trigger(e,3,n,"location_current",{accuracy:i,priority:t})},this.permission=function(i){window.natively.trigger(e,6,i,"location_permission")},this.start=function(i,t,n,o){window.natively.trigger(e,3,o,"location_start",{accuracy:t,priority:n,interval:i})},this.stop=function(){window.natively.trigger(e,3,void 0,"location_stop",{})},this.startBackground=function(i,t,n,o,r){const s={};s.identifier=void 0===o?"empty":o,s.interval=void 0===i?6e4:i,s.accuracy=void 0===t?50:t,s.priority=void 0===n?"BALANCED":n,window.natively.trigger(e,4,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 r={};r.subject=void 0===i?"":i,r.body=void 0===t?"":t,r.recipient=void 0===n?"":n,window.natively.trigger(e,0,o,"send_email",r)}}}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,r){let s={};s.type=void 0===n?"DATE":n,s.style=void 0===o?"LIGHT":o,s.title=void 0===i?"":i,s.description=void 0===t?"":t,window.natively.trigger(e,0,r,"datepicker",s)}}}class NativelyCamera{constructor(){const e=generateID();this.showCamera=function(i,t,n,o){let r={};r.type=void 0===i?"photo":i,r.quality=void 0===t?"high":t,r.camera=void 0===n?"BACK":n,window.natively.trigger(e,2,o,"open_camera",r)}}}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){window.natively.trigger(e,3,t,"purchases_login",{login:i})},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.purchasePackage=function(i,t){window.natively.trigger(e,3,t,"purchases_package",{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,r){let s={firstName:i};s.lastName=void 0===t?"":t,s.email=void 0===n?"":n,s.phone=void 0===o?"":o,window.natively.trigger(e,3,r,"contacts_save",s)}}}
|