Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
componentDidMount() {
UrbanAirship.isUserNotificationsEnabled().then ((enabled) => {
this.setState({notificationsEnabled:enabled})
})
UrbanAirship.isLocationEnabled().then ((enabled) => {
this.setState({locationEnabled:enabled})
})
UrbanAirship.addListener("notificationResponse", (response) => {
console.log('notificationResponse:', JSON.stringify(response));
alert("notificationResponse: " + response.notification.alert);
});
UrbanAirship.addListener("pushReceived", (notification) => {
console.log('pushReceived:', JSON.stringify(notification));
alert("pushReceived: " + notification.alert);
});
UrbanAirship.addListener("deepLink", (event) => {
console.log('deepLink:', JSON.stringify(event));
alert("deepLink: " + event.deepLink);
});
UrbanAirship.addListener("registration", (event) => {
console.log('registration:', JSON.stringify(event));
this.state.channelId = event.channelId;
this.setState(this.state);
});
UrbanAirship.addListener("notificationOptInStatus", (event) => {
UrbanAirship.isLocationEnabled().then ((enabled) => {
this.setState({locationEnabled:enabled})
})
UrbanAirship.addListener("notificationResponse", (response) => {
console.log('notificationResponse:', JSON.stringify(response));
alert("notificationResponse: " + response.notification.alert);
});
UrbanAirship.addListener("pushReceived", (notification) => {
console.log('pushReceived:', JSON.stringify(notification));
alert("pushReceived: " + notification.alert);
});
UrbanAirship.addListener("deepLink", (event) => {
console.log('deepLink:', JSON.stringify(event));
alert("deepLink: " + event.deepLink);
});
UrbanAirship.addListener("registration", (event) => {
console.log('registration:', JSON.stringify(event));
this.state.channelId = event.channelId;
this.setState(this.state);
});
UrbanAirship.addListener("notificationOptInStatus", (event) => {
console.log('notificationOptInStatus:', JSON.stringify(event));
});
}
console.log('pushReceived:', JSON.stringify(notification));
alert("pushReceived: " + notification.alert);
});
UrbanAirship.addListener("deepLink", (event) => {
console.log('deepLink:', JSON.stringify(event));
alert("deepLink: " + event.deepLink);
});
UrbanAirship.addListener("registration", (event) => {
console.log('registration:', JSON.stringify(event));
this.state.channelId = event.channelId;
this.setState(this.state);
});
UrbanAirship.addListener("notificationOptInStatus", (event) => {
console.log('notificationOptInStatus:', JSON.stringify(event));
});
}
console.log('pushReceived:', JSON.stringify(notification));
alert("pushReceived: " + notification.alert);
});
UrbanAirship.addListener("deepLink", (event) => {
console.log('deepLink:', JSON.stringify(event));
alert("deepLink: " + event.deepLink);
});
UrbanAirship.addListener("registration", (event) => {
console.log('registration:', JSON.stringify(event));
this.state.channelId = event.channelId;
this.setState(this.state);
});
UrbanAirship.addListener("notificationOptInStatus", (event) => {
console.log('notificationOptInStatus:', JSON.stringify(event));
});
}
componentDidMount() {
UrbanAirship.isUserNotificationsEnabled().then ((enabled) => {
this.setState({notificationsEnabled:enabled})
})
UrbanAirship.isLocationEnabled().then ((enabled) => {
this.setState({locationEnabled:enabled})
})
UrbanAirship.addListener("notificationResponse", (response) => {
console.log('notificationResponse:', JSON.stringify(response));
alert("notificationResponse: " + response.notification.alert);
});
UrbanAirship.addListener("pushReceived", (notification) => {
console.log('pushReceived:', JSON.stringify(notification));
alert("pushReceived: " + notification.alert);
});
UrbanAirship.addListener("deepLink", (event) => {
console.log('deepLink:', JSON.stringify(event));
alert("deepLink: " + event.deepLink);
});
UrbanAirship.addListener("registration", (event) => {
console.log('registration:', JSON.stringify(event));
initalizePushNotifications() {
UrbanAirship.setUserNotificationsEnabled(true)
UrbanAirship.addListener("register", (event) => {
console.log('Channel registration updated: ', event.channelId);
console.log('Registration token: ', event.registrationToken);
});
UrbanAirship.addListener("pushReceived", (notification) => {
console.log('Received push: ', JSON.stringify(notification));
});
UrbanAirship.setForegroundPresentationOptions({
alert: true,
sound: true,
badge: true
});
}
const { notificationsEnabled } = this.props.state
UrbanAirship.setUserNotificationsEnabled(notificationsEnabled)
UrbanAirship.addListener("pushReceived", async(notification) => {
const actions = JSON.parse(notification.extras['com.urbanairship.actions'])
const { type } = actions
if(type === 'NewPendingCredit') {
loadingPending.wrap(this.props.getPending())
} else if(type === 'NewFriendRequest') {
loadingFriends.wrap(this.props.getFriends())
} else if(type === 'RequestPayPal') {
loadingPayPalRequests.wrap(this.props.getPayPalRequests())
}
})
UrbanAirship.addListener("notificationResponse", async(incoming) => {
try{
const actions = JSON.parse(incoming.notification.extras['com.urbanairship.actions'])
const { type, user } = actions
if(type === 'NewPendingCredit') {
const { route, pendingTransaction, pendingSettlement } = this.props.getPendingFromFriend(user)
if(pendingTransaction !== undefined || pendingSettlement !== undefined) {
navigation.navigate(route, { pendingTransaction, pendingSettlement })
}
} else if(type === 'RequestPayPal') {
const friend = this.props.getFriendFromNick(user)
navigation.navigate('Settlement', { friend, settlementType: 'paypal' })
} else {
navigation.navigate('Activity')
}
} catch(e) {}
async initializePushNotifications() {
const { navigation } = this.props
UrbanAirship.getChannelId().then(channelId => {
if (channelId) {
this.props.registerChannelID(channelId, Platform.OS)
}
})
const { notificationsEnabled } = this.props.state
UrbanAirship.setUserNotificationsEnabled(notificationsEnabled)
UrbanAirship.addListener("pushReceived", async(notification) => {
const actions = JSON.parse(notification.extras['com.urbanairship.actions'])
const { type } = actions
if(type === 'NewPendingCredit') {
loadingPending.wrap(this.props.getPending())
} else if(type === 'NewFriendRequest') {
loadingFriends.wrap(this.props.getFriends())
} else if(type === 'RequestPayPal') {
loadingPayPalRequests.wrap(this.props.getPayPalRequests())
}
})
UrbanAirship.addListener("notificationResponse", async(incoming) => {
try{
const actions = JSON.parse(incoming.notification.extras['com.urbanairship.actions'])
const { type, user } = actions