Commit 3c311b79 authored by Afid's avatar Afid

handler notification and add icon for notification

parent f2c03d89
......@@ -12,8 +12,8 @@ import i18n from 'i18n-js';
import en from './lib/en';
import id from './lib/id';
import React, { useState, useEffect } from 'react';
import { Text, View } from 'react-native';
import { AppLoading } from 'expo';
import { Alert, Vibration } from 'react-native';
import { AppLoading, Notifications } from 'expo';
import * as Font from 'expo-font';
import * as Sentry from 'sentry-expo';
import Constants from 'expo-constants';
......@@ -58,8 +58,48 @@ 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') {
} else if (data.action_type == 'Transaction') {
} else if (data.action_type == 'Review') {
} else if (data.action_type == 'WebView') {
} else if (data.action_type == 'Transfer Receive') {
} else if (data.action_type == 'Cashback') {
}
}
},
],
{ cancelable: false },
)
}
useEffect(() => {
console.log('===> Did Mount');
this._notificationSubscription = Notifications.addListener(handleNotification);
loadFont().then(_ => {
setfontsLoaded(true);
})
......
......@@ -30,7 +30,7 @@
},
"android": {
"package": "local.ravExcelso",
"versionCode": 20200327
"versionCode": 2005151310
},
"description": "",
"hooks": {
......@@ -45,6 +45,9 @@
}
}
]
},
"notification": {
"icon": "./assets/icon/notification.png"
}
}
}
\ 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