Compare commits
2 Commits
0ae599d8f8
...
ded5516bb1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ded5516bb1 | ||
|
|
77651e2e95 |
@ -1,6 +1,7 @@
|
||||
import Flutter
|
||||
import UIKit
|
||||
import UserNotifications
|
||||
import Firebase
|
||||
|
||||
@main
|
||||
@objc class AppDelegate: FlutterAppDelegate {
|
||||
@ -8,11 +9,18 @@ import UserNotifications
|
||||
_ application: UIApplication,
|
||||
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
|
||||
) -> Bool {
|
||||
|
||||
FirebaseApp.configure()
|
||||
|
||||
// Set notification delegate so notifications show in foreground & background
|
||||
UNUserNotificationCenter.current().delegate = self
|
||||
|
||||
GeneratedPluginRegistrant.register(with: self)
|
||||
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
|
||||
|
||||
return super.application(
|
||||
application,
|
||||
didFinishLaunchingWithOptions: launchOptions
|
||||
)
|
||||
}
|
||||
|
||||
// Called when a notification is delivered while app is in foreground
|
||||
@ -24,7 +32,7 @@ import UserNotifications
|
||||
completionHandler([.banner, .badge, .sound])
|
||||
}
|
||||
|
||||
// Called when user taps a notification (foreground or background)
|
||||
// Called when user taps a notification
|
||||
override func userNotificationCenter(
|
||||
_ center: UNUserNotificationCenter,
|
||||
didReceive response: UNNotificationResponse,
|
||||
|
||||
8
ios/Runner/Runner.entitlements
Normal file
8
ios/Runner/Runner.entitlements
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>aps-environment</key>
|
||||
<string>development</string>
|
||||
</dict>
|
||||
</plist>
|
||||
@ -43,13 +43,8 @@ class LoginFormBloc extends Bloc<LoginFormEvent, LoginFormState> {
|
||||
|
||||
if (emailValid && passwordValid) {
|
||||
// Ambil device info dan FCM token secara paralel
|
||||
final results = await Future.wait([
|
||||
_deviceInfoService.getDeviceInfo(),
|
||||
_fcmService.getToken(),
|
||||
]);
|
||||
|
||||
final deviceInfo = results[0] as DeviceInfo;
|
||||
final fcmToken = results[1] as String?;
|
||||
final deviceInfo = await _deviceInfoService.getDeviceInfo();
|
||||
final fcmToken = await _fcmService.getToken();
|
||||
|
||||
failureOrAuth = await _repository.login(
|
||||
email: state.email,
|
||||
|
||||
@ -194,7 +194,15 @@ class FcmService {
|
||||
}
|
||||
|
||||
/// Returns the FCM registration token for this device.
|
||||
Future<String?> getToken() => _messaging.getToken();
|
||||
/// Returns null if token is unavailable (e.g. simulator, APNs not ready).
|
||||
Future<String?> getToken() async {
|
||||
try {
|
||||
return await _messaging.getToken();
|
||||
} catch (e) {
|
||||
debugPrint('[FCM] getToken failed: $e');
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// Subscribe to a topic (e.g. 'all', 'promo').
|
||||
Future<void> subscribeToTopic(String topic) =>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user