rn-push-notifications-ql
v1.0.1
Published
A custom push notifications package for react native
Downloads
13
Maintainers
Readme
REACT-NATIVE-PUSH-NOTIFICATIONS-QL
Dependencies needed
Use this command to install the npm packages listed below
- @react-native-community/push-notification-ios
- @react-native-firebase/app
- @react-native-firebase/auth
- @react-native-firebase/messaging
- react
- react-native
- react-native-push-notification
Steps for React Native Push Notifications in IOS
- Create firebase app for IOS
- Add following lines in Podfile located inside ios folder
- $RNFirebaseAsStaticFramewor = true at top of the file
- use_frameworks! :linkage => :static at top of the file
- Add following lines in AppDelegate.mm file located inside ios/project_name folder
- #import <Firebase.h> at top of the file
- [FIRApp configure]; at top of the didFinishLaunchingWithOptions function
- Add GoogleService-Info.plist inside ./ios/project_name using xcode by right clicking on project name folder then add file.
- After completing above steps do pod install inside ios folder
- Run app using 'npm run android for Android and 'npm run ios for IOS.
Usage
Install Dependeny
npm i rn-push-notifications-ql yarn add rn-push-notifications-ql
Import the package
import { LocalNotification, PictureNotification, MultilineNotification, requestUserPermission } from 'rn-push-notifications-ql';
Then call the component
const onLocalNotificationPress = () => {
try {
LocalNotification(
title="Local Notification title||",
message="Hey this is a notification message.",
bigText="This is a big text||",
subText="This is a subtext",
channelDescription="This is channel description",
playSound=true,
soundName="default",
vibrate=true,
);
console.log('call me')
} catch (err) {
console.log(err);
}
};
const onImageNotificationPress = () => {
try {
PictureNotification(
title="Image Notification title||",
message="Hey this is a notification message.",
bigText="This is a big text||",
subText="This is a subtext",
channelDescription="This is channel description",
playSound=true,
soundName="default",
vibrate=true,
image=IMAGE_URL
);
console.log('call me')
} catch (err) {
console.log(err);
}
};
const onMultiLineNotificationPress = () => {
try {
MultilineNotification(
title="Mltiline Notification title||",
message="Hey this is a notification message.",
bigText=`
This is a big text||
This is a big text||
This is a big text||
This is a big text||
This is a big text||
This is a big text||
This is a big text||
This is a big text||
This is a big text||`,
subText="This is a subtext",
channelDescription="This is channel description",
playSound=true,
soundName="default",
vibrate=true,
);
console.log('call me')
} catch (err) {
console.log(err);
}
};
React.useEffect(() => {
requestUserPermission((token) => {
console.log({ token });
});
}, []);