Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 6 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
source 'https://rubygems.org'

# You may use http://rbenv.org/ or https://rvm.io/ to install and use this version
ruby '>= 2.6.10'

gem 'cocoapods', '>= 1.11.3'
15 changes: 3 additions & 12 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
module.exports = function (api) {
api && api.cache(false);
return {
presets: [
'module:metro-react-native-babel-preset'
],
plugins: [
'@babel/plugin-proposal-export-namespace-from',
'@babel/plugin-proposal-export-default-from'
]
};
};
module.exports = {
presets: ['module:@react-native/babel-preset'],
};
59 changes: 0 additions & 59 deletions example/.gitignore

This file was deleted.

2 changes: 1 addition & 1 deletion example/.watchmanconfig
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{}
{}
117 changes: 117 additions & 0 deletions example/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
*/

import type {PropsWithChildren} from 'react';
import {
SafeAreaView,
ScrollView,
StatusBar,
StyleSheet,
Text,
useColorScheme,
View,
} from 'react-native';

import {
Colors,
DebugInstructions,
Header,
LearnMoreLinks,
ReloadInstructions,
} from 'react-native/Libraries/NewAppScreen';

type SectionProps = PropsWithChildren<{
title: string;
}>;

function Section({children, title}: SectionProps): React.JSX.Element {
const isDarkMode = useColorScheme() === 'dark';
return (
<View style={styles.sectionContainer}>
<Text
style={[
styles.sectionTitle,
{
color: isDarkMode ? Colors.white : Colors.black,
},
]}>
{title}
</Text>
<Text
style={[
styles.sectionDescription,
{
color: isDarkMode ? Colors.light : Colors.dark,
},
]}>
{children}
</Text>
</View>
);
}

function App(): React.JSX.Element {
const isDarkMode = useColorScheme() === 'dark';

const backgroundStyle = {
backgroundColor: isDarkMode ? Colors.darker : Colors.lighter,
};

return (
<SafeAreaView style={backgroundStyle}>
<StatusBar
barStyle={isDarkMode ? 'light-content' : 'dark-content'}
backgroundColor={backgroundStyle.backgroundColor}
/>
<ScrollView
contentInsetAdjustmentBehavior="automatic"
style={backgroundStyle}>
<Header />
<View
style={{
backgroundColor: isDarkMode ? Colors.black : Colors.white,
}}>
<Section title="Step One">
Edit <Text style={styles.highlight}>App.tsx</Text> to change this
screen and then come back to see your edits.
</Section>
<Section title="See Your Changes">
<ReloadInstructions />
</Section>
<Section title="Debug">
<DebugInstructions />
</Section>
<Section title="Learn More">
Read the docs to discover what to do next:
</Section>
<LearnMoreLinks />
</View>
</ScrollView>
</SafeAreaView>
);
}

const styles = StyleSheet.create({
sectionContainer: {
marginTop: 32,
paddingHorizontal: 24,
},
sectionTitle: {
fontSize: 24,
fontWeight: '600',
},
sectionDescription: {
marginTop: 8,
fontSize: 18,
fontWeight: '400',
},
highlight: {
fontWeight: '700',
},
});

export default App;
78 changes: 42 additions & 36 deletions example/NotificationsExampleApp.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, {useState, useEffect} from 'react';
import {useState, useEffect} from 'react';
import {
StyleSheet,
View,
Expand All @@ -8,8 +8,8 @@ import {
} from 'react-native';
import {
Notifications,
NotificationAction,
NotificationCategory,
// NotificationAction,
// NotificationCategory,
NotificationBackgroundFetchResult,
Notification,
} from '../lib/src';
Expand All @@ -20,69 +20,75 @@ export default function NotificationsExampleApp() {

useEffect(() => {
registerNotificationEvents();
setCategories();
// setCategories();
getInitialNotification();
}, [])

const registerNotificationEvents = () => {
Notifications.events().registerNotificationReceivedForeground((notification, completion) => {
console.log('registerNotificationReceivedForeground', notification);
setNotifications([...notifications, notification]);
completion({alert: notification.payload.showAlert, sound: false, badge: false});
});

Notifications.events().registerNotificationOpened((notification, completion) => {
setOpenedNotifications([notification, ...openedNotifications]);
completion();
});

Notifications.events().registerNotificationReceivedBackground((notification, completion) => {
console.log('registerNotificationReceivedBackground', notification);
completion(NotificationBackgroundFetchResult.NO_DATA);
});

Notifications.events().registerRemoteNotificationsRegistered((event) => {
console.log('registerRemoteNotificationsRegistered', event);
});

if (Platform.OS === 'ios') {
Notifications.ios.events().appNotificationSettingsLinked(() => {
console.warn('App Notification Settings Linked')
});
}
}

const requestPermissionsIos = (options) => {
const requestPermissionsIos = (options: string[]) => {
Notifications.ios.registerRemoteNotifications(
Object.fromEntries(options.map(opt => [opt, true]))
Object.fromEntries(options.map((opt: string) => [opt, true]))
);
}

const requestPermissions = () => {
Notifications.registerRemoteNotifications();
}

const setCategories = () => {
const upvoteAction = new NotificationAction(
'UPVOTE_ACTION',
'background',
String.fromCodePoint(0x1F44D),
false,
);

const replyAction = new NotificationAction(
'REPLY_ACTION',
'background',
'Reply',
true,
{
buttonTitle: 'Reply now',
placeholder: 'Insert message'
},
);


const category = new NotificationCategory(
'SOME_CATEGORY',
[upvoteAction, replyAction]
);

Notifications.setCategories([category]);
}
// const setCategories = () => {
// const upvoteAction = new NotificationAction(
// 'UPVOTE_ACTION',
// 'background',
// String.fromCodePoint(0x1F44D),
// false,
// );

// const replyAction = new NotificationAction(
// 'REPLY_ACTION',
// 'background',
// 'Reply',
// true,
// {
// buttonTitle: 'Reply now',
// placeholder: 'Insert message'
// },
// );


// const category = new NotificationCategory(
// 'SOME_CATEGORY',
// [upvoteAction, replyAction]
// );

// Notifications.setCategories;
// }

const sendLocalNotification = () => {
Notifications.postLocalNotification({
Expand Down Expand Up @@ -128,7 +134,7 @@ export default function NotificationsExampleApp() {
}
}

const renderNotification = (notification) => {
const renderNotification = (notification: Notification) => {
return (
<View style={{backgroundColor: 'lightgray', margin: 10}}>
<Text>{`Title: ${notification.title}`}</Text>
Expand All @@ -138,7 +144,7 @@ export default function NotificationsExampleApp() {
);
}

const renderOpenedNotification = (notification) => {
const renderOpenedNotification = (notification: Notification) => {
return (
<View style={{backgroundColor: 'lightgray', margin: 10}}>
<Text>{`Title: ${notification.title}`}</Text>
Expand Down
8 changes: 0 additions & 8 deletions example/android/.gitignore

This file was deleted.

Loading
Loading