Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
useEffect(() => {
getData();
OneSignal.init(ONE_SIGNAL_APP_KEY);
OneSignal.addEventListener('received', onReceived);
OneSignal.addEventListener('opened', onOpened);
OneSignal.addEventListener('ids', onIds);
return () => {
OneSignal.removeEventListener('received', this.onReceived);
OneSignal.removeEventListener('opened', this.onOpened);
OneSignal.removeEventListener('ids', this.onIds);
};
}, []);
useEffect(() => {
getData();
OneSignal.init(ONE_SIGNAL_APP_KEY);
OneSignal.addEventListener('received', onReceived);
OneSignal.addEventListener('opened', onOpened);
OneSignal.addEventListener('ids', onIds);
return () => {
OneSignal.removeEventListener('received', this.onReceived);
OneSignal.removeEventListener('opened', this.onOpened);
OneSignal.removeEventListener('ids', this.onIds);
};
}, []);
componentDidMount() {
OneSignal.init(ONESIGNAL_APP_ID, {kOSSettingsKeyAutoPrompt: false})
OneSignal.addEventListener('received', this.onReceived)
OneSignal.addEventListener('opened', this.onOpened)
OneSignal.addEventListener('ids', this.onIds)
}
bindNotificationListeners(){
OneSignal.addEventListener('received', (notification) => {
console.log('received notification!', notification);
return false;
});
OneSignal.addEventListener('ids',(device) => {
console.log('received device info: ', device);
});
OneSignal.addEventListener('opened', (opened) => {
console.log('Opened notification', opened);
const notificationData = opened.notification.payload.additionalData;
if( this.navigator ){
this.handlePushNotification(notificationData);
} else {
this.initialNotification = notificationData;
}
});
}
componentDidMount() {
OneSignal.init(ONESIGNAL_APP_ID, {kOSSettingsKeyAutoPrompt: false})
OneSignal.addEventListener('received', this.onReceived)
OneSignal.addEventListener('opened', this.onOpened)
OneSignal.addEventListener('ids', this.onIds)
}
bindNotificationListeners(){
OneSignal.addEventListener('received', (notification) => {
console.log('received notification!', notification);
return false;
});
OneSignal.addEventListener('ids',(device) => {
console.log('received device info: ', device);
});
OneSignal.addEventListener('opened', (opened) => {
console.log('Opened notification', opened);
const notificationData = opened.notification.payload.additionalData;
if( this.navigator ){
this.handlePushNotification(notificationData);
} else {
this.initialNotification = notificationData;
}
});
}
handlePushNotification(notification){
constructor(props) {
super(props);
this.deviceID = ''
OneSignal.init("df4cae47-cd9d-4dd5-b97f-5f63593f39fb")
OneSignal.inFocusDisplaying(2)
OneSignal.addEventListener('received', this.onReceived);
OneSignal.addEventListener('opened', this.onOpened);
OneSignal.addEventListener('ids', device => {
this.deviceID = device.userId
});
OneSignal.configure();
this.state = {
checked: false,
count: 0,
isLoading: false,
data: [
{
id: '1',
seller: 'grosir.outdoor.shop',
description: '1 KG 1 Roll Wallpaper 10 meter X 45 cm wallpaper dinding Motif hellokitty doraemon dll',
image: 'https://cf.shopee.co.id/file/webp/6e060dc67897556a6065a1e93750521d_tn',
constructor(props) {
super(props);
this.deviceID = ''
OneSignal.init("df4cae47-cd9d-4dd5-b97f-5f63593f39fb")
OneSignal.inFocusDisplaying(2)
OneSignal.addEventListener('received', this.onReceived);
OneSignal.addEventListener('opened', this.onOpened);
OneSignal.addEventListener('ids', device => {
this.deviceID = device.userId
});
OneSignal.configure();
this.state = {
checked: false,
count: 0,
isLoading: false,
data: [
{
id: '1',
seller: 'grosir.outdoor.shop',
description: '1 KG 1 Roll Wallpaper 10 meter X 45 cm wallpaper dinding Motif hellokitty doraemon dll',
image: 'https://cf.shopee.co.id/file/webp/6e060dc67897556a6065a1e93750521d_tn',
price: 'Rp 25.000'
componentWillMount() {
OneSignal.inFocusDisplaying(2);
OneSignal.addEventListener('ids', this.onIds);
OneSignal.addEventListener('registered', this.onPNRegistered);
OneSignal.addEventListener('received', this.onReceived);
OneSignal.addEventListener('opened', this.onOpened);
this.unsubscribe = store.subscribe(this.onStoreUpdate);
this.unsubscribeCreate = KitsuLibrary.subscribe(KitsuLibraryEvents.LIBRARY_ENTRY_CREATE, this.onLibraryEntryCreated);
this.unsubscribeUpdate = KitsuLibrary.subscribe(KitsuLibraryEvents.LIBRARY_ENTRY_UPDATE, this.onLibraryEntryUpdated);
this.unsubscribeDelete = KitsuLibrary.subscribe(KitsuLibraryEvents.LIBRARY_ENTRY_DELETE, this.onLibraryEntryDeleted);
}