Commit 68612dd5 authored by Afid's avatar Afid

notification sekarang bisa navigate

parent 7446a597
......@@ -17,6 +17,9 @@ import { AppLoading, Notifications } from 'expo';
import * as Font from 'expo-font';
import * as Sentry from 'sentry-expo';
import Constants from 'expo-constants';
import { navigationRef } from './helper/RootNavigation';
import * as RootNavigation from './helper/RootNavigation';
Sentry.init({
dsn: 'https://ae2449ac801244d99f170140c7cd6d0a@o392471.ingest.sentry.io/5239999',
......@@ -58,42 +61,52 @@ export default function App() {
await Font.loadAsync(customFonts);
};
const handleNotification = notification => {
Vibration.vibrate();
console.log('Notification Payload Data : ' + JSON.stringify(notification.data))
const data = notification.data;
Alert.alert(
data.title,
data.body,
[
{
text: 'Close',
onPress: () => console.log('Close'),
style: 'cancel',
},
{
text: 'View', onPress: () => {
console.log('Pindah Halaman')
if (data.action_type == 'Rewards') {
// props.navigation.navigate('Reward Detail', { rewardId: data.data_id })
} else if (data.action_type == 'Inbox') {
const routing = (data) => {
if (data.action_type == 'Rewards') {
RootNavigation.navigate('Reward Detail', { rewardId: data.data_id });
} else if (data.action_type == 'Inbox') {
} else if (data.action_type == 'Transaction') {
} else if (data.action_type == 'Transaction') {
RootNavigation.navigate('Transaction Detail', {idTrans:data.data_id});
} else if (data.action_type == 'Review') {
} else if (data.action_type == 'Review') {
} else if (data.action_type == 'WebView') {
} else if (data.action_type == 'WebView') {
} else if (data.action_type == 'Transfer Receive') {
} else if (data.action_type == 'Transfer Receive') {
} else if (data.action_type == 'Cashback') {
} else if (data.action_type == 'Cashback') {
}
}
const handleNotification = notification => {
// console.log('Notification Origin : ' + JSON.stringify(notification.origin))
// console.log('Notification Payload Data : ' + JSON.stringify(notification.data))
const origin = notification.origin;
const data = notification.data;
if (origin == 'selected') {
routing(data)
} else {
Vibration.vibrate();
Alert.alert(
data.title,
data.body,
[
{
text: 'Close',
style: 'cancel',
},
{
text: 'View', onPress: () => {
routing(data)
}
}
},
],
{ cancelable: false },
)
},
],
{ cancelable: false },
)
}
}
......@@ -111,7 +124,7 @@ export default function App() {
return (
<Provider store={store}>
<PersistGate loading={null} persistor={persistor}>
<NavigationContainer>
<NavigationContainer ref={navigationRef}>
<Auth />
</NavigationContainer>
</PersistGate>
......
import * as React from 'react';
export const navigationRef = React.createRef();
export function navigate(name, params) {
navigationRef.current?.navigate(name, params);
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment