- Created Info.plist with essential app configuration including bundle identifiers, versioning, and URL schemes. - Added PrivacyInfo.xcprivacy to specify accessed API types and privacy tracking settings. - Implemented SplashScreen.storyboard for the app's launch screen with a logo and background color. - Established Expo.plist for update configurations, setting updates to check on launch. - Created a bridging header for Swift compatibility. - Added an empty entitlements file for future use.
49 lines
1.2 KiB
TypeScript
49 lines
1.2 KiB
TypeScript
import * as Notifications from 'expo-notifications';
|
|
import React, { useEffect } from "react";
|
|
import { Button, Platform, Text, View } from "react-native";
|
|
|
|
async function registerForPushNotificationsAsync() {
|
|
const { status: existingStatus } = await Notifications.getPermissionsAsync();
|
|
let finalStatus = existingStatus;
|
|
if (existingStatus !== 'granted') {
|
|
const { status } = await Notifications.requestPermissionsAsync();
|
|
finalStatus = status;
|
|
}
|
|
if (finalStatus !== 'granted') {
|
|
alert('Permission for notifications not granted!');
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
async function sendNotification() {
|
|
await Notifications.scheduleNotificationAsync({
|
|
content: {
|
|
title: "Hello!",
|
|
body: "Ez egy értesítés példája.",
|
|
},
|
|
trigger: Platform.OS === 'android'
|
|
? ({ seconds: 1, repeats: false } as any)
|
|
: null,
|
|
});
|
|
}
|
|
|
|
export default function Index() {
|
|
useEffect(() => {
|
|
registerForPushNotificationsAsync();
|
|
}, []);
|
|
|
|
return (
|
|
<View
|
|
style={{
|
|
flex: 1,
|
|
justifyContent: "center",
|
|
alignItems: "center",
|
|
}}
|
|
>
|
|
<Text>Edit app/index.tsx to edit this screen.</Text>
|
|
<Button title="Küldj értesítést" onPress={sendNotification} />
|
|
</View>
|
|
);
|
|
}
|