-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
121 lines (109 loc) · 3.97 KB
/
App.js
File metadata and controls
121 lines (109 loc) · 3.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
import React, { useEffect, useState } from 'react';
import { StatusBar } from 'expo-status-bar';
import { NavigationContainer } from '@react-navigation/native';
import { SafeAreaProvider } from 'react-native-safe-area-context';
import { ThemeProvider } from './src/context/ThemeContext';
import { NotesProvider } from './src/context/NotesContext';
import { LanguageProvider } from './src/context/LanguageContext';
import { Platform } from 'react-native';
import { requestTrackingPermissionsAsync } from 'expo-tracking-transparency';
import Constants from 'expo-constants';
import AppNavigator from './src/navigation/AppNavigator';
import StopwatchService from './src/services/StopwatchService';
import NotificationService from './src/services/NotificationService';
import AsyncStorage from '@react-native-async-storage/async-storage';
import OnboardingScreen from './src/screens/OnboardingScreen';
export default function App() {
const [onboardingChecked, setOnboardingChecked] = useState(false);
const [showOnboarding, setShowOnboarding] = useState(false);
// İlk açılışta onboarding kontrolü
useEffect(() => {
(async () => {
try {
const flag = await AsyncStorage.getItem('hasSeenOnboarding');
setShowOnboarding(flag !== 'true');
} catch {}
setOnboardingChecked(true);
})();
}, []);
// Bildirim servisini her platformda başlat (Expo Go dahil)
useEffect(() => {
(async () => {
try {
await NotificationService.initialize();
} catch {}
})();
}, []);
useEffect(() => {
// iOS ATT iznini uygulama açılışında iste
(async () => {
try {
if (Platform.OS === 'ios' && Constants?.appOwnership !== 'expo') {
const { status } = await requestTrackingPermissionsAsync();
// İzin durumu: 'granted' | 'denied' | 'unavailable'
// Burada ileride GDPR/CCPA için reklam talebini kişisel/kişisel olmayan şekle ayarlayabiliriz.
}
} catch (e) {
console.warn('ATT permission request failed:', e?.message || e);
}
})();
// iOS/Android yerel derlemede reklam SDK başlatma (Expo Go'da devre dışı)
if (Platform.OS !== 'web' && Constants?.appOwnership !== 'expo') {
try {
const { default: mobileAds } = require('react-native-google-mobile-ads');
mobileAds().initialize();
} catch (e) {
console.warn('MobileAds init failed:', e?.message || e);
}
}
// Expo Go veya web ortamında bildirimleri tamamen devre dışı bırak
if (Platform.OS === 'web' || (Constants?.appOwnership === 'expo')) {
return;
}
let Notifications = null;
try {
Notifications = require('expo-notifications');
} catch {}
if (!Notifications) return;
Notifications.setNotificationHandler({
handleNotification: async () => ({
shouldShowBanner: true,
shouldShowList: true,
shouldPlaySound: true,
shouldSetBadge: false,
}),
});
if (Platform.OS === 'android') {
(async () => {
try {
await Notifications.setNotificationChannelAsync('inactivity', {
name: 'Inactivity',
importance: Notifications.AndroidImportance.HIGH,
sound: 'default',
vibrationPattern: [0, 250, 250, 250],
lockscreenVisibility: Notifications.AndroidNotificationVisibility.PUBLIC,
});
} catch {}
})();
}
// Şimdilik izin isteme veya bildirim planlama yok
}, []);
return (
<SafeAreaProvider>
<LanguageProvider>
<ThemeProvider>
<NotesProvider>
<NavigationContainer>
<StatusBar style="auto" />
{onboardingChecked && showOnboarding ? (
<OnboardingScreen onDone={() => setShowOnboarding(false)} />
) : (
<AppNavigator />
)}
</NavigationContainer>
</NotesProvider>
</ThemeProvider>
</LanguageProvider>
</SafeAreaProvider>
);
}