0.0.2 • Published 3 years ago
@epnsproject/sdk-uimobile v0.0.2
uimobile
Package for React Native based mobile apps.
How to use in your Mobile app?
Installation
yarn add @epnsproject/sdk-uimobileor
npm install @epnsproject/sdk-uimobile Please read this carefullly
We need to install peer dependencies for @epnsproject/sdk-uimobile in your mobile app. And have it set up as below to make it run.
yarn add @react-native-masked-view/masked-view react-native-svg react-native-video react-native-youtubeThen for different types of react native apps use the below instructions.
FOR EXPO APPS
expo install expo-file-system
expo install expo-linear-gradientRunning IOS
cd ios && pod installyarn iosViewPropTypes Error -
If you get below error
Invariant Violation: ViewPropTypes has been removed from React Native. Migrate to ViewPropTypes exported from 'deprecated-react-native-prop-types'ViewPropTypes Error Fix
- In
node_modules/react-native/index.jsReplace the below code
// Deprecated Prop Types
get ColorPropType(): $FlowFixMe {
invariant(
false,
"ColorPropType has been removed from React Native. Migrate to " +
"ColorPropType exported from 'deprecated-react-native-prop-types'.",
);
},
get EdgeInsetsPropType(): $FlowFixMe {
invariant(
false,
"EdgeInsetsPropType has been removed from React Native. Migrate to " +
"EdgeInsetsPropType exported from 'deprecated-react-native-prop-types'.",
);
},
get PointPropType(): $FlowFixMe {
invariant(
false,
"PointPropType has been removed from React Native. Migrate to " +
"PointPropType exported from 'deprecated-react-native-prop-types'.",
);
},
get ViewPropTypes(): $FlowFixMe {
invariant(
false,
"ViewPropTypes has been removed from React Native. Migrate to " +
"ViewPropTypes exported from 'deprecated-react-native-prop-types'.",
);
},with below snippet
// Deprecated Prop Types
get ColorPropType(): $FlowFixMe {
return require("deprecated-react-native-prop-types").ColorPropType
},
get EdgeInsetsPropType(): $FlowFixMe {
return require("deprecated-react-native-prop-types").EdgeInsetsPropType
},
get PointPropType(): $FlowFixMe {
return require("deprecated-react-native-prop-types").PointPropType
},
get ViewPropTypes(): $FlowFixMe {
return require("deprecated-react-native-prop-types").ViewPropTypes
},yarn add patch-packagenpx patch-package react-nativecd ios && pod installyarn ios
Image.propTypes.resizeMode error
ERROR TypeError: undefined is not an object (evaluating '_reactNative.Image.propTypes.resizeMode')then use this
Image.propTypes fix
After that,
npx patch-package react-native-video
cd ios && pod install
yarn iosRunning Android
If you get this Error
Could not find com.yqritc:android-scalablevideoview:1.0.4.
Required by:
project :react-native-videoadd this in android/build.gradle
jcenter() {
content {
includeModule("com.yqritc", "android-scalablevideoview")
}
}Run yarn android
FOR REACT NATIVE CLI GENERATED APPS
npx install-expo-modules
expo install expo-file-system
expo install expo-linear-gradientcd iOS && pod install
yarn iOSSimilarly, if you get this ViewPropTypes error then use this fix
and ImagePropTypes error then use this fix
Notification Item View
Import in your file
import { Notification, parseApiResponse } from "@epnsproject/sdk-uimobile";Inside JSX,
After you get the Notification data from the API, you parse it with the parseApiResponse helper
const [notifData, setNotifData] = React.useState([]);
// fetch data, parse and set it in state
const apiResponse = await fetchNotifications(user, parseInt(pageSize));
const parsedResults = parseApiResponse(apiResponse.results);
setNotifData(parsedResults); <View style={styles.list}>
{notifData.map((oneNotification: any, idx: number) => {
const {cta, title, message, app, icon, image, blockchain, appbot } = oneNotification;
return (
<Notification
key={idx}
notificationTitle={title}
notificationBody={message}
cta={cta}
app={app}
icon={icon}
image={image}
chainName={blockchain}
appbot={appbot}
youTubeAPIKey={config.YOUTUBE_API_KEY} // pass your YOUTUBE_API_KEY here
/>
);
})}
</View>where
| Prop | Type | Remarks |
|---|---|---|
| notificationTitle | string | Title of the notification (given during notification creation) |
| notificationBody | number | Message body of the notification (given during notification creation) |
| icon | string | Channel Icon (IPFS url) (given during channel setup) |
| app | string | Channel Name (given during channel setup) |
| cta | string | Call To Action Link (given during notification creation) |
| image | string | Any media link (given during notification creation) |
| appbot | string | is the notification is from EPNS bot the value is "1" else "0" |
| chainName | string | Can be anyone of the following blockchain networks on which the notification was sent - "ETH_MAINNET", "ETH_TEST_GOERLI", "POLYGON_MAINNET", "POLYGON_TEST_MUMBAI", "THE_GRAPH" |
| youTubeAPIKey | string | Your generated Youtube API key |