Closed rajatgalav closed 4 years ago
Howdy, Can you please include a code example?
Fiirst i imported the onesignal library in my component.
import OneSignal from 'react-native-onesignal';
then added event listener in componentDidMount and removed it in componentWillUnmount
componentDidMount() {
OneSignal.removeTriggerForKey("level");
OneSignal.addEventListener('inAppMessageClicked', this.onInAppClicked);
}
componentWillUnmount() {
OneSignal.removeEventListener('inAppMessageClicked', this.onInAppClicked);
}
for onInappClicked i wrote
onInAppClicked = (action) => {
OneSignal.getTriggerValueForKey("level", function (value) {
console.log("level:==>", value)
});
console.log('in app action is=>>', action)
const {click_name} = action
OneSignal.removeTriggerForKey("level");
this.props.navigation.navigate(click_name)
}
and onclick of a button i write
OneSignal.addTrigger("level", true);
OneSignal.getTriggerValueForKey("level", function (value) {
console.log("level:==>", value)
});
Howdy, Can you please include a code example?
I used setLogLevel to log the errors. It is prompting error ERROR In-App message with id ' ////// ' already displayed or is already preparing to be display!
@rajatgalav I am not able to reproduce this issue you are having. I even implemented the example you showed here and nothing seemed to be wrong. Are you experiencing this in Android, iOS, or both?
Also setLogLevel VERBOSE will show you all OneSignal logs, so try this:
setLogLevel(6, 0)
And just to clarify this In-App message id was not actually '//////'
, right?
@mikechoch right now i am trying it in android, not sure about ios. setLogLevel(6, 0)
it was not working so i changed it to setLogLevel(0, 6)
.
Does setLogLevel(6, 0)
this show logs on browser console ?
Yes '////////' it was not shown in the message. Their was and id of numbers.
Also i think
OneSignal.addTrigger("level", true);
OneSignal.getTriggerValueForKey("level", function (value) {
console.log("level:==>", value)
});
these statements does not work sequentially.
When i checked node modules getTriggerValueForKey
does not accept callback function.
@rgomezp getTriggerValueForKey
is returning '' empty string. It should return null value if the trigger is not added, according to the documentation.
Thanks for the catch. We will update the documentation to reflect the correct return value. Enjoy!
Documentation says method getTriggerValueForKey
accepts callback as a second argument, while this method really returns a Promise and accepts only one argument. This should be fixed in docs.
I installed onesignal using command
npm install react-native-onesignal@^3.5.0
It installed version 3.6.2Everything is working except when trying to
removeTriggerForKey
key is not removed. I am able to add the trigger and in app message is shown but when i click on it i am trying to remove the key. But it is not working.Also
getTriggerValueForKey
is also not working.