Navigate on notification open
This commit is contained in:
parent
a0a2be9878
commit
3fd1528ae7
40
App.js
40
App.js
|
@ -76,6 +76,7 @@ import CreateGroupNanoCredit from './screens/nano-credit/CreateGroupNanoCredit';
|
||||||
import { bindActionCreators } from 'redux';
|
import { bindActionCreators } from 'redux';
|
||||||
import DemandValidationGroup from './screens/nano-credit/DemandGroupNanoCredit';
|
import DemandValidationGroup from './screens/nano-credit/DemandGroupNanoCredit';
|
||||||
import DemandGroupNanoCreditDetail from './screens/nano-credit/DemandGroupNanoCreditDetail';
|
import DemandGroupNanoCreditDetail from './screens/nano-credit/DemandGroupNanoCreditDetail';
|
||||||
|
import NavigationService from './utils/NavigationService';
|
||||||
|
|
||||||
const instructions = Platform.select({
|
const instructions = Platform.select({
|
||||||
ios: 'Press Cmd+R to reload,\n' + 'Cmd+D or shake for dev menu',
|
ios: 'Press Cmd+R to reload,\n' + 'Cmd+D or shake for dev menu',
|
||||||
|
@ -397,6 +398,7 @@ class App extends React.Component {
|
||||||
|
|
||||||
onOpened(openResult) {
|
onOpened(openResult) {
|
||||||
let data = openResult.notification.payload.additionalData;
|
let data = openResult.notification.payload.additionalData;
|
||||||
|
NavigationService.navigate('useraccount');
|
||||||
console.log('Message: ', openResult.notification.payload.body);
|
console.log('Message: ', openResult.notification.payload.body);
|
||||||
console.log('Data: ', openResult.notification.payload.additionalData);
|
console.log('Data: ', openResult.notification.payload.additionalData);
|
||||||
console.log('isActive: ', openResult.notification.isAppInFocus);
|
console.log('isActive: ', openResult.notification.isAppInFocus);
|
||||||
|
@ -421,12 +423,48 @@ class App extends React.Component {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleDeepLink = openResult => {
|
||||||
|
const data = openResult.notification.payload.additionalData;
|
||||||
|
//this.props.setInitialNotification(openResult);
|
||||||
|
if (data && data.id) {
|
||||||
|
/* this.goToScreen(data.screen, {
|
||||||
|
id: data.id,
|
||||||
|
goToScreen: this.goToScreen
|
||||||
|
}); */
|
||||||
|
this.goToScreen("useraccount", {
|
||||||
|
goToScreen: this.goToScreen
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
console.log("notification is invalid data");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
goToScreen = (routeName, params, isReset = true) => {
|
||||||
|
const { navigator } = this.refs;
|
||||||
|
navigator.dispatch({
|
||||||
|
type: "Navigation/NAVIGATE",
|
||||||
|
routeName,
|
||||||
|
params
|
||||||
|
});
|
||||||
|
|
||||||
|
// if (isReset) {
|
||||||
|
// const resetAction = NavigationActions.reset({
|
||||||
|
// index: 0,
|
||||||
|
// actions: [NavigationActions.navigate({routeName, params})]
|
||||||
|
// });
|
||||||
|
// navigator.dispatch(resetAction);
|
||||||
|
// } else {
|
||||||
|
// navigator.dispatch({type: 'Navigation/NAVIGATE', routeName: routeName, params});
|
||||||
|
// }
|
||||||
|
// this.closeSideMenu();
|
||||||
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<Provider store={store}>
|
<Provider store={store}>
|
||||||
<PersistGate persistor={persistor}>
|
<PersistGate persistor={persistor}>
|
||||||
<ActionSheetProvider>
|
<ActionSheetProvider>
|
||||||
<AppContainer />
|
<AppContainer ref="navigator" />
|
||||||
</ActionSheetProvider>
|
</ActionSheetProvider>
|
||||||
</PersistGate>
|
</PersistGate>
|
||||||
</Provider>
|
</Provider>
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -51,6 +51,7 @@ import { connect } from 'react-redux';
|
||||||
import getWalletActivated from '../../webservice/WalletApi';
|
import getWalletActivated from '../../webservice/WalletApi';
|
||||||
import { saveOnesignalIdsAction } from '../../webservice/OnesignalApi';
|
import { saveOnesignalIdsAction } from '../../webservice/OnesignalApi';
|
||||||
import OneSignal from 'react-native-onesignal';
|
import OneSignal from 'react-native-onesignal';
|
||||||
|
import NavigationService from '../../utils/NavigationService';
|
||||||
|
|
||||||
|
|
||||||
const slideHeight = responsiveHeight(30) > 270 ? 270 : responsiveHeight(30)
|
const slideHeight = responsiveHeight(30) > 270 ? 270 : responsiveHeight(30)
|
||||||
|
@ -658,14 +659,14 @@ class Home extends BaseScreen {
|
||||||
|
|
||||||
OneSignal.addEventListener('received', this.onReceived);
|
OneSignal.addEventListener('received', this.onReceived);
|
||||||
OneSignal.addEventListener('opened', this.onOpened);
|
OneSignal.addEventListener('opened', this.onOpened);
|
||||||
OneSignal.addEventListener('ids', this.onIds);
|
//OneSignal.addEventListener('ids', this.onIds);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
OneSignal.removeEventListener('received', this.onReceived);
|
OneSignal.removeEventListener('received', this.onReceived);
|
||||||
OneSignal.removeEventListener('opened', this.onOpened);
|
OneSignal.removeEventListener('opened', this.onOpened);
|
||||||
OneSignal.removeEventListener('ids', this.onIds);
|
//OneSignal.removeEventListener('ids', this.onIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
onReceived(notification) {
|
onReceived(notification) {
|
||||||
|
@ -674,9 +675,12 @@ class Home extends BaseScreen {
|
||||||
|
|
||||||
onOpened(openResult) {
|
onOpened(openResult) {
|
||||||
let data = openResult.notification.payload.additionalData;
|
let data = openResult.notification.payload.additionalData;
|
||||||
this.props.navigation.navigate(data.screen, {
|
this.props.navigation.push()
|
||||||
|
/* this.props.navigation.navigate(data.screen, {
|
||||||
id: data.data.id
|
id: data.data.id
|
||||||
});
|
}); */
|
||||||
|
//NavigationService.navigate('useraccount');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* updateLangue() {
|
/* updateLangue() {
|
||||||
|
|
|
@ -24,6 +24,7 @@ import Dialog from "react-native-dialog";
|
||||||
import { FontWeight } from '../../config/typography'
|
import { FontWeight } from '../../config/typography'
|
||||||
import DeviceInfo from 'react-native-device-info'
|
import DeviceInfo from 'react-native-device-info'
|
||||||
import { getNanoCreditUniqueDemandsAction, getNanoCreditUniqueDemandsReset } from '../../webservice/user/NanoCreditApi'
|
import { getNanoCreditUniqueDemandsAction, getNanoCreditUniqueDemandsReset } from '../../webservice/user/NanoCreditApi'
|
||||||
|
import { treatDemandGroupAction, treatDemandGroupReset } from '../../webservice/NanoCreditApi'
|
||||||
|
|
||||||
class DemandGroupNanoCreditDetail extends Component {
|
class DemandGroupNanoCreditDetail extends Component {
|
||||||
|
|
||||||
|
@ -118,16 +119,21 @@ class DemandGroupNanoCreditDetail extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
onTreatDemand() {
|
onTreatDemand() {
|
||||||
if (this.item !== "1") {
|
this.props.treatDemandGroupReset();
|
||||||
this.props.creditDemandResetReducer();
|
this.props.treatDemandGroupAction({
|
||||||
this.props.treatCreditDemand(this.item.id);
|
id_demande: this.props.resultGetUniqueDemand.response.id,
|
||||||
}
|
id_user: this.state.user.id,
|
||||||
|
type: "creation"
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
onCancelDemand = () => {
|
onCancelDemand = () => {
|
||||||
if (this.item !== "1") {
|
this.props.treatDemandGroupReset();
|
||||||
this.props.treatCancelDemand(this.item.id);
|
this.props.treatDemandGroupAction({
|
||||||
}
|
id_demande: this.props.resultGetUniqueDemand.response.id,
|
||||||
|
id_user: this.state.user.id,
|
||||||
|
type: "suppression"
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -291,10 +297,10 @@ class DemandGroupNanoCreditDetail extends Component {
|
||||||
}}
|
}}
|
||||||
isLoading={this.props.loadingTreatDemand}
|
isLoading={this.props.loadingTreatDemand}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
/* this.setState({
|
this.setState({
|
||||||
triggerTreatmentClick: true
|
triggerTreatmentClick: true
|
||||||
});
|
});
|
||||||
this.onTreatDemand() */
|
this.onTreatDemand();
|
||||||
}}
|
}}
|
||||||
textStyle={styles.textbtnstyle}
|
textStyle={styles.textbtnstyle}
|
||||||
>
|
>
|
||||||
|
@ -316,10 +322,10 @@ class DemandGroupNanoCreditDetail extends Component {
|
||||||
}}
|
}}
|
||||||
isLoading={this.props.loadingCancelDemand}
|
isLoading={this.props.loadingCancelDemand}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
/* this.setState({
|
this.setState({
|
||||||
triggerCancelClick: true
|
triggerCancelClick: true
|
||||||
});
|
});
|
||||||
this.onCancelDemand(); */
|
this.onCancelDemand();
|
||||||
}}
|
}}
|
||||||
textStyle={styles.textbtnstyle}
|
textStyle={styles.textbtnstyle}
|
||||||
>
|
>
|
||||||
|
@ -481,6 +487,7 @@ class DemandGroupNanoCreditDetail extends Component {
|
||||||
//ago = moment(ago)
|
//ago = moment(ago)
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
{(this.state.triggerTreatmentClick || this.state.triggerCancelClick) && this.renderAlertErrorTreatOrCancelDemand()}
|
||||||
{
|
{
|
||||||
this.props.loadingGetUniqueDemand ?
|
this.props.loadingGetUniqueDemand ?
|
||||||
this.renderLoader() :
|
this.renderLoader() :
|
||||||
|
@ -507,6 +514,9 @@ const mapDispatchToProps = dispatch => bindActionCreators({
|
||||||
getNanoCreditUniqueDemandsAction: getNanoCreditUniqueDemandsAction,
|
getNanoCreditUniqueDemandsAction: getNanoCreditUniqueDemandsAction,
|
||||||
getNanoCreditUniqueDemandsReset: getNanoCreditUniqueDemandsReset,
|
getNanoCreditUniqueDemandsReset: getNanoCreditUniqueDemandsReset,
|
||||||
|
|
||||||
|
treatDemandGroupAction: treatDemandGroupAction,
|
||||||
|
treatDemandGroupReset: treatDemandGroupReset,
|
||||||
|
|
||||||
treatCreditDemand: treatCreditDemand,
|
treatCreditDemand: treatCreditDemand,
|
||||||
creditDemandResetReducer: creditDemandResetReducer,
|
creditDemandResetReducer: creditDemandResetReducer,
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
import { NavigationActions } from 'react-navigation';
|
||||||
|
|
||||||
|
let _navigator;
|
||||||
|
|
||||||
|
function setTopLevelNavigator(navigatorRef) {
|
||||||
|
_navigator = navigatorRef;
|
||||||
|
}
|
||||||
|
|
||||||
|
function navigate(routeName, params) {
|
||||||
|
_navigator.dispatch(
|
||||||
|
NavigationActions.navigate({
|
||||||
|
routeName,
|
||||||
|
params,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// add other navigation functions that you need and export them
|
||||||
|
|
||||||
|
export default {
|
||||||
|
navigate,
|
||||||
|
setTopLevelNavigator,
|
||||||
|
};
|
|
@ -53,6 +53,7 @@ export const getCreditDemand = testBaseUrl + '/walletService/groups/demands';
|
||||||
|
|
||||||
export const linkCardUrl = testBaseUrl + '/walletService/identifications/rattach_card';
|
export const linkCardUrl = testBaseUrl + '/walletService/identifications/rattach_card';
|
||||||
export const groupUrl = testBaseUrl + '/walletService/groups';
|
export const groupUrl = testBaseUrl + '/walletService/groups';
|
||||||
|
export const treatDemandUrl = testBaseUrl + '/walletService/groups/demands/validate';
|
||||||
export const saveOnesignalIds = testBaseUrl + '/notificationService/onesignal';
|
export const saveOnesignalIds = testBaseUrl + '/notificationService/onesignal';
|
||||||
|
|
||||||
export const authKeyUrl = testBaseUrl + '/oauth/token';
|
export const authKeyUrl = testBaseUrl + '/oauth/token';
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
|
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import I18n from 'react-native-i18n';
|
import I18n from 'react-native-i18n';
|
||||||
import { fetchCreateGroupError, fetchCreateGroupPending, fetchCreateGroupReset, fetchCreateGroupSuccess } from "../redux/actions/NanoCreditAction";
|
import { fetchCreateGroupError, fetchCreateGroupPending, fetchCreateGroupReset, fetchCreateGroupSuccess, fetchTreatDemandsGroupPending, fetchTreatDemandsGroupSuccess, fetchTreatDemandsGroupError, fetchTreatDemandsGroupReset } from "../redux/actions/NanoCreditAction";
|
||||||
import { store } from "../redux/store";
|
import { store } from "../redux/store";
|
||||||
import { groupUrl } from "./IlinkConstants";
|
import { groupUrl, treatDemandUrl } from "./IlinkConstants";
|
||||||
|
|
||||||
export const createGroupAction = (data) => {
|
export const createGroupAction = (data) => {
|
||||||
|
|
||||||
|
@ -42,3 +42,41 @@ export const createGroupReset = () => {
|
||||||
dispatch(fetchCreateGroupReset());
|
dispatch(fetchCreateGroupReset());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const treatDemandGroupAction = (data) => {
|
||||||
|
|
||||||
|
const auth = store.getState().authKeyReducer;
|
||||||
|
const authKey = auth !== null ? `${auth.authKey.token_type} ${auth.authKey.access_token}` : '';
|
||||||
|
|
||||||
|
return dispatch => {
|
||||||
|
dispatch(fetchTreatDemandsGroupPending());
|
||||||
|
|
||||||
|
axios({
|
||||||
|
url: `${treatDemandUrl}`,
|
||||||
|
method: 'POST',
|
||||||
|
data,
|
||||||
|
headers: {
|
||||||
|
'Authorization': authKey,
|
||||||
|
'X-Localization': I18n.currentLocale()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.then(response => {
|
||||||
|
console.log(response);
|
||||||
|
dispatch(fetchTreatDemandsGroupSuccess(response));
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
if (error.response)
|
||||||
|
dispatch(fetchTreatDemandsGroupError(error.response));
|
||||||
|
else if (error.request)
|
||||||
|
dispatch(fetchTreatDemandsGroupError(error.request))
|
||||||
|
else
|
||||||
|
dispatch(fetchTreatDemandsGroupError(error.message))
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const treatDemandGroupReset = () => {
|
||||||
|
return dispatch => {
|
||||||
|
dispatch(fetchTreatDemandsGroupReset());
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue