Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display prompt after X pageviews #70

Closed
ivptr opened this issue Jun 20, 2021 · 2 comments · Fixed by #82
Closed

Display prompt after X pageviews #70

ivptr opened this issue Jun 20, 2021 · 2 comments · Fixed by #82
Labels
enhancement New feature or request

Comments

@ivptr
Copy link

ivptr commented Jun 20, 2021

Instead of displaying prompt right away to the new visitor, would like to display it after X pageviews, to be less intrusive.

Using the following for OneSignal:

jQuery(document).ready(function($) {

	window.OneSignal = window.OneSignal || [];
	var numVisitsTrigger = 3; /* Number of page visits before prompting user */

	window.OneSignal.push(function() {
		var numVisits = new Number(localStorage['numVisitsTrigger'] || 0);
		numVisits += 1;
		localStorage['numVisitsTrigger'] = numVisits;
		if (numVisits >= numVisitsTrigger) {
			promptAndSubscribeUser();
		}
	});

	function promptAndSubscribeUser() {
		window.OneSignal.isPushNotificationsEnabled(function(isEnabled) {
			if (!isEnabled) {
				// Show Slide Prompt
				window.OneSignal.showSlidedownPrompt();
			}
		});
	}

});
@rwngallego
Copy link
Collaborator

This is part of the improvements to the permission prompt, adding it to the backlog. Thanks! :)

@rwngallego
Copy link
Collaborator

This has been released in v1.3.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
2 participants