philfung / add-to-homescreen

Easily add a website to home screen on IOS/Android/Desktop
MIT License
127 stars 35 forks source link

how to close guides?How to not display the guidance process for the second time? #2

Closed FairyWorld closed 1 year ago

FairyWorld commented 1 year ago

how to close guides?How to not display the guidance process for the second time?

philfung commented 1 year ago

hi @FairyWorld .

how to close guides

  1. Set flag allowUserToCloseModal to true.
  2. The user can then click outside of the modal (ie in the black region) to close the modal.

Please note that (from experience), allowing the user to close the modal will decrease the home screen installation rate.

How to not display the guidance process for the second time?

Ive just added a new flag maxModalDisplayCount . you can set this to 1 to show the modal at most once, 2 to show the modal at most 2 times, etc Note again that this will decrease the home screen installation rate.


document.addEventListener('DOMContentLoaded', function () {

window.AddToHomeScreenInstance = new window.AddToHomeScreen(
{
appName: 'Aardvark',                                   // Name of the app
appIcon: 'apple-touch-icon.png',                       // App icon link (square, at least 40 x 40 pixels)
assetUrl: 'https://cdn.jsdelivr.net/gh/philfung/add-to-homescreen@1.4/dist/assets/img/',  // Link to directory of library image assets 
showErrorMessageForUnsupportedBrowsers: true,          // Should we prompt users on non-compliant browsers (like IOS Firefox) to switch to compliant one (like Safari) Default: true.
allowUserToCloseModal: true,                           // Allow user to close the 'Add to Homescreen' message? Not allowing will increase installs. Default: false.
maxModalDisplayCount: 1                                // If set, the modal will only show this many times.
                                                        // Default is -1 (no limit).  (Debugging: Use this.clearModalDisplayCount() to reset the count)
}
);

ret = window.AddToHomeScreenInstance.show();             // show "add-to-homescreen" instructions to user, or do nothing if already added to homescreen
});

Thank you.