natively 2.0.0 → 2.1.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 +36 -20
- package/natively-frontend.min.js +1 -1
- package/package.json +1 -1
package/natively-frontend.js
CHANGED
|
@@ -135,7 +135,7 @@ window.natively = {
|
|
|
135
135
|
showAppToast(type, text) {
|
|
136
136
|
const params = {};
|
|
137
137
|
params.text = typeof text === "undefined" ? "" : text;
|
|
138
|
-
params.type = typeof type === "undefined" ?
|
|
138
|
+
params.type = typeof type === "undefined" ? "DEFAULT" : type;
|
|
139
139
|
window.natively.trigger(undefined, 0, undefined, "show_toast", params);
|
|
140
140
|
},
|
|
141
141
|
|
|
@@ -253,7 +253,7 @@ class NativelyInfo {
|
|
|
253
253
|
}
|
|
254
254
|
}
|
|
255
255
|
|
|
256
|
-
// WebPage Caching
|
|
256
|
+
// WebPage Caching Not Available
|
|
257
257
|
class NativelyPagesCache {
|
|
258
258
|
constructor() {
|
|
259
259
|
const id = generateID();
|
|
@@ -323,19 +323,35 @@ class NativelyGeolocation {
|
|
|
323
323
|
class NativelyLocation {
|
|
324
324
|
constructor() {
|
|
325
325
|
const id = generateID();
|
|
326
|
-
|
|
326
|
+
// priority_android = HIGH or BALANCED
|
|
327
|
+
// accuracy_ios = 0 - 5000 m
|
|
328
|
+
this.current = function (accuracy_ios, priority_android, location_callback) {
|
|
327
329
|
window.natively.trigger(id, 3, location_callback, "location_current", {
|
|
328
|
-
accuracy,
|
|
330
|
+
accuracy: accuracy_ios,
|
|
331
|
+
priority: priority_android
|
|
329
332
|
});
|
|
330
333
|
};
|
|
331
|
-
this.start = function (
|
|
334
|
+
this.start = function (interval, accuracy_ios, priority_android, location_callback) {
|
|
332
335
|
window.natively.trigger(id, 3, location_callback, "location_start", {
|
|
333
|
-
accuracy,
|
|
336
|
+
accuracy: accuracy_ios,
|
|
337
|
+
priority: priority_android,
|
|
338
|
+
interval
|
|
334
339
|
});
|
|
335
340
|
};
|
|
336
341
|
this.stop = function () {
|
|
337
342
|
window.natively.trigger(id, 3, undefined, "location_stop", {});
|
|
338
343
|
};
|
|
344
|
+
this.startBackground = function (interval, accuracy_ios, priority_android, responseIdentifier, location_bg_callback) {
|
|
345
|
+
const params = {};
|
|
346
|
+
params.identifier = typeof responseIdentifier === "undefined" ? "empty" : responseIdentifier;
|
|
347
|
+
params.interval = typeof interval === "undefined" ? 1000 * 60 : interval;
|
|
348
|
+
params.accuracy = typeof accuracy_ios === "undefined" ? 50 : accuracy_ios;
|
|
349
|
+
params.priority = typeof priority_android === "undefined" ? "BALANCED" : priority_android;
|
|
350
|
+
window.natively.trigger(id, 4, location_bg_callback, "location_start_bg", params);
|
|
351
|
+
};
|
|
352
|
+
this.stopBackground = function (location_bg_callback) {
|
|
353
|
+
window.natively.trigger(id, 4, location_bg_callback, "location_stop_bg", {});
|
|
354
|
+
};
|
|
339
355
|
}
|
|
340
356
|
}
|
|
341
357
|
|
|
@@ -344,15 +360,15 @@ class NativelyMessage {
|
|
|
344
360
|
const id = generateID();
|
|
345
361
|
this.sendSMS = function (body, recipient, send_sms_callback) {
|
|
346
362
|
const params = {};
|
|
347
|
-
params.body = typeof body === undefined ? "" : body;
|
|
348
|
-
params.recipient = typeof recipient === undefined ? "" : recipient;
|
|
363
|
+
params.body = typeof body === "undefined" ? "" : body;
|
|
364
|
+
params.recipient = typeof recipient === "undefined" ? "" : recipient;
|
|
349
365
|
window.natively.trigger(id, 0, send_sms_callback, "send_sms", params);
|
|
350
366
|
};
|
|
351
367
|
this.sendEmail = function (subject, body, recipient, send_email_callback) {
|
|
352
368
|
const params = {};
|
|
353
|
-
params.subject = typeof subject === undefined ? "" : subject;
|
|
354
|
-
params.body = typeof body === undefined ? "" : body;
|
|
355
|
-
params.recipient = typeof recipient === undefined ? "" : recipient;
|
|
369
|
+
params.subject = typeof subject === "undefined" ? "" : subject;
|
|
370
|
+
params.body = typeof body === "undefined" ? "" : body;
|
|
371
|
+
params.recipient = typeof recipient === "undefined" ? "" : recipient;
|
|
356
372
|
window.natively.trigger(id, 0, send_email_callback, "send_email", params);
|
|
357
373
|
};
|
|
358
374
|
}
|
|
@@ -467,10 +483,10 @@ class NativelyDatePicker {
|
|
|
467
483
|
datepicker_callback
|
|
468
484
|
) {
|
|
469
485
|
let params = {};
|
|
470
|
-
params.type = typeof type === undefined ? "DATE" : type;
|
|
471
|
-
params.style = typeof style === undefined ? "LIGHT" : style;
|
|
472
|
-
params.title = typeof title === undefined ? "" : title;
|
|
473
|
-
params.description = typeof description === undefined ? "" : description;
|
|
486
|
+
params.type = typeof type === "undefined" ? "DATE" : type;
|
|
487
|
+
params.style = typeof style === "undefined" ? "LIGHT" : style;
|
|
488
|
+
params.title = typeof title === "undefined" ? "" : title;
|
|
489
|
+
params.description = typeof description === "undefined" ? "" : description;
|
|
474
490
|
window.natively.trigger(id, 0, datepicker_callback, "datepicker", params);
|
|
475
491
|
};
|
|
476
492
|
}
|
|
@@ -481,8 +497,8 @@ class NativelyCamera {
|
|
|
481
497
|
const id = generateID();
|
|
482
498
|
this.showCamera = function (type, quality, open_camera_callback) {
|
|
483
499
|
let params = {};
|
|
484
|
-
params.type = typeof type === undefined ? "photo" : type;
|
|
485
|
-
params.quality = typeof quality === undefined ? "high" : quality;
|
|
500
|
+
params.type = typeof type === "undefined" ? "photo" : type;
|
|
501
|
+
params.quality = typeof quality === "undefined" ? "high" : quality;
|
|
486
502
|
window.natively.trigger(
|
|
487
503
|
id,
|
|
488
504
|
2,
|
|
@@ -545,9 +561,9 @@ class NativelyContacts {
|
|
|
545
561
|
contacts_save_callback
|
|
546
562
|
) {
|
|
547
563
|
let params = { firstName };
|
|
548
|
-
params.lastName = typeof lastName === undefined ? "" : lastName;
|
|
549
|
-
params.email = typeof email === undefined ? "" : email;
|
|
550
|
-
params.phone = typeof phone === undefined ? "" : phone;
|
|
564
|
+
params.lastName = typeof lastName === "undefined" ? "" : lastName;
|
|
565
|
+
params.email = typeof email === "undefined" ? "" : email;
|
|
566
|
+
params.phone = typeof phone === "undefined" ? "" : phone;
|
|
551
567
|
window.natively.trigger(
|
|
552
568
|
id,
|
|
553
569
|
3,
|
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,t){window.natively.injected=!0,e&&(window.natively.min_app_version=e),t&&(window.natively.app_version=t);const i=window.natively.observers;for(natively.isDebug&&console.log("[INFO] Notify observers: ",i.length);i.length>0;){const e=i.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,t,i,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(i){let t;t=e?n+"_response_"+e: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: ${e}`),i(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,t,i,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,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){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,t){const i={};i.text=void 0===t?"":t,i.type=void 0===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,t){window.natively.injected=!0,e&&(window.natively.min_app_version=e),t&&(window.natively.app_version=t);const i=window.natively.observers;for(natively.isDebug&&console.log("[INFO] Notify observers: ",i.length);i.length>0;){const e=i.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,t,i,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(i){let t;t=e?n+"_response_"+e: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: ${e}`),i(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,t,i,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,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){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,t){const 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){const n={};n.type=void 0===e?"INFO":e,n.title=void 0===t?"":t,n.description=void 0===i?"":i,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 t={color:e};window.natively.trigger(void 0,1,void 0,"app_background",t)},setAppProgressColor(e){const t={color:e};window.natively.trigger(void 0,1,void 0,"app_progress",t)},setAppSwipeNavigationIOS(e){const t={toggle:e};window.natively.trigger(void 0,1,void 0,"app_navigation",t)},setAppPullToRefresh(e){const t={toggle:e};window.natively.trigger(void 0,1,void 0,"app_pull",t)},setAppOrientation(e){const t={orientation:e};window.natively.trigger(void 0,3,void 0,"app_orientation",t)},setAppStatusBarStyleIOS(e){const t={style:e};window.natively.trigger(void 0,2,void 0,"status_bar_style",t)},async sendPushNotification(e,t,i,n){const o=i.filter(e=>e.length>0),r=[...new Set(o)];let s={app_id:n?"be83022a-1d08-45d0-a07a-0c3655666e17":e,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,e=>{window.natively.min_app_version=e.minSDKVersion,window.natively.app_version=e.sdkVersion},"app_info",{}));class NativelyInfo{constructor(){const e=generateID();this.getAppInfo=function(t){window.natively.trigger(e,0,t,"app_info")},this.connectivity=function(e){window.natively.trigger(void 0,0,e,"connectivity")}}}class NativelyPagesCache{constructor(){const 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(){const 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(){const 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(){const e=generateID();this.current=function(t,i,n){window.natively.trigger(e,3,n,"location_current",{accuracy:t,priority:i})},this.start=function(t,i,n,o){window.natively.trigger(e,3,o,"location_start",{accuracy:i,priority:n,interval:t})},this.stop=function(){window.natively.trigger(e,3,void 0,"location_stop",{})},this.startBackground=function(t,i,n,o,r){const s={};s.identifier=void 0===o?"empty":o,s.interval=void 0===t?6e4:t,s.accuracy=void 0===i?50:i,s.priority=void 0===n?"BALANCED":n,window.natively.trigger(e,4,r,"location_start_bg",s)},this.stopBackground=function(t){window.natively.trigger(e,4,t,"location_stop_bg",{})}}}class NativelyMessage{constructor(){const e=generateID();this.sendSMS=function(t,i,n){const o={};o.body=void 0===t?"":t,o.recipient=void 0===i?"":i,window.natively.trigger(e,0,n,"send_sms",o)},this.sendEmail=function(t,i,n,o){const r={};r.subject=void 0===t?"":t,r.body=void 0===i?"":i,r.recipient=void 0===n?"":n,window.natively.trigger(e,0,o,"send_email",r)}}}class NativelyStorage{constructor(){const 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;const 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,n,o){window.natively.trigger(t,0,o,"biometrics_auth",{allowPass:e,login:i,password:n})}}}class NativelyDatePicker{constructor(){const e=generateID();this.showDatePicker=function(t,i,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===i?"":i,window.natively.trigger(e,0,r,"datepicker",s)}}}class NativelyCamera{constructor(){const e=generateID();this.showCamera=function(t,i,n){let o={};o.type=void 0===t?"photo":t,o.quality=void 0===i?"high":i,window.natively.trigger(e,2,n,"open_camera",o)}}}class NativelyScanner{constructor(){const e=generateID();this.showScanner=function(t){window.natively.trigger(e,2,t,"open_scanner",{})}}}class NativelyPurchases{constructor(){const e=generateID();this.login=function(t,i){window.natively.trigger(e,3,i,"purchases_login",{login:t})},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.purchasePackage=function(t,i){window.natively.trigger(e,3,i,"purchases_package",{packageId:t})}}}class NativelyContacts{constructor(){const e=generateID();this.getAllContacts=function(t){window.natively.trigger(e,3,t,"contacts_all",{})},this.createContact=function(t,i,n,o,r){let s={firstName:t};s.lastName=void 0===i?"":i,s.email=void 0===n?"":n,s.phone=void 0===o?"":o,window.natively.trigger(e,3,r,"contacts_save",s)}}}
|