OneSignal / OneSignal-Flutter-SDK

OneSignal is a free push notification service for mobile apps. This plugin makes it easy to integrate your flutter app with OneSignal
https://www.onesignal.com
Other
625 stars 214 forks source link

[question]: When to use `removeTrigger` ? #774

Closed DanMossa closed 7 months ago

DanMossa commented 1 year ago

How can we help?

I'm having trouble with users not being subscribed to Notifications and my current theory is to try using InAppMessages to enable Notifications.

I want a popup to appear when I want to ask the user to enable permissions.

On OneSignal, I've created an InAppMessage with the following triggers and schedule image

In my Code, I'm using the following: await OneSignal.InAppMessages.addTrigger('showPermissionPrompt', "true");

This then makes the notification appear. Do I then have to await OneSignal.InAppMessages.removeTrigger('showPermissionPrompt'); afterwards unless the Popup will happen every-time the user opens the app?

Just looking for clarification. Thanks!

Code of Conduct

nan-li commented 9 months ago

Hi @DanMossa,

Thank you for your question and I do apologize for the delayed response.

Calling OneSignal.InAppMessages.addTrigger('showPermissionPrompt', "true") will make the in-app message (IAM) display every time you add the trigger, so yes, if you add the trigger on every app open, it will happen.

The primary purpose of the removeTrigger method is for compound events. For example, you may have an IAM display when two triggers are satisfied.

Perhaps you add the first trigger and then add the second trigger, then the IAM will display.

However, if you add the first trigger, then remove the first trigger, then add the second trigger, the IAM will not display.

Hope this makes sense.