Skip to content

Commit

Permalink
feat(Bonus Pagamenti Digitali): [#176093031] Setup Mixpanel push noti…
Browse files Browse the repository at this point in the history
…fication (#2555)

* [#176093031] add support

* [#176093031] add bottom margin inside a badge
  • Loading branch information
Undermaken authored Dec 14, 2020
1 parent e407fa0 commit 0cff182
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
6 changes: 6 additions & 0 deletions ts/boot/configurePushNotification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { NonEmptyString } from "italia-ts-commons/lib/strings";
import { Alert } from "react-native";
import PushNotification from "react-native-push-notification";

import { constNull } from "fp-ts/lib/function";
import { store } from "../App";
import { debugRemotePushNotification, gcmSenderId } from "../config";
import { loadMessages } from "../store/actions/messages";
Expand All @@ -16,6 +17,7 @@ import {
updateNotificationsPendingMessage
} from "../store/actions/notifications";
import { isDevEnv } from "../utils/environment";
import { setMixpanelPushNotificationToken } from "../mixpanel";

/**
* Helper type used to validate the notification payload.
Expand All @@ -36,6 +38,10 @@ function configurePushNotifications() {
PushNotification.configure({
// Called when token is generated
onRegister: token => {
// set push notification token on mixpanel
setMixpanelPushNotificationToken(token.token)
.then(constNull)
.catch(constNull);
// Dispatch an action to save the token in the store
store.dispatch(updateNotificationsInstallationToken(token.token));
},
Expand Down
14 changes: 12 additions & 2 deletions ts/components/wallet/PaymentMethodsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@
*/
import { Badge, ListItem, Text, View } from "native-base";
import * as React from "react";
import { Alert, FlatList, ListRenderItemInfo, StyleSheet } from "react-native";
import {
Alert,
FlatList,
ListRenderItemInfo,
Platform,
StyleSheet
} from "react-native";
import { connect } from "react-redux";
import { Option } from "fp-ts/lib/Option";
import { H3 } from "../core/typography/H3";
Expand Down Expand Up @@ -61,7 +67,11 @@ const styles = StyleSheet.create({
descriptionPadding: { paddingRight: 24 },

badgeContainer: { height: 18, backgroundColor: IOColors.blue },
badgeText: { fontSize: 12, lineHeight: 18 }
badgeText: {
fontSize: 12,
lineHeight: 18,
marginBottom: Platform.select({ android: 2, default: 0 })
}
});

export const showPaymentMethodIncomingAlert = () =>
Expand Down
7 changes: 7 additions & 0 deletions ts/mixpanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,10 @@ const setupMixpanel = async (mp: MixpanelInstance) => {
// Identify the user using the device uniqueId
await mp.identify(DeviceInfo.getUniqueId());
};

export const setMixpanelPushNotificationToken = (token: string) => {
if (mixpanel) {
return mixpanel.setPushRegistrationId(token);
}
return Promise.resolve();
};

0 comments on commit 0cff182

Please sign in to comment.