Compare commits
No commits in common. "ded5516bb1b952dd91631ac603a2dcfb4a9b120a" and "0ae599d8f8d4d74b87c2df90d867c527d1e2018a" have entirely different histories.
ded5516bb1
...
0ae599d8f8
@ -1,7 +1,6 @@
|
|||||||
import Flutter
|
import Flutter
|
||||||
import UIKit
|
import UIKit
|
||||||
import UserNotifications
|
import UserNotifications
|
||||||
import Firebase
|
|
||||||
|
|
||||||
@main
|
@main
|
||||||
@objc class AppDelegate: FlutterAppDelegate {
|
@objc class AppDelegate: FlutterAppDelegate {
|
||||||
@ -9,18 +8,11 @@ import Firebase
|
|||||||
_ application: UIApplication,
|
_ application: UIApplication,
|
||||||
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
|
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
|
||||||
) -> Bool {
|
) -> Bool {
|
||||||
|
|
||||||
FirebaseApp.configure()
|
|
||||||
|
|
||||||
// Set notification delegate so notifications show in foreground & background
|
// Set notification delegate so notifications show in foreground & background
|
||||||
UNUserNotificationCenter.current().delegate = self
|
UNUserNotificationCenter.current().delegate = self
|
||||||
|
|
||||||
GeneratedPluginRegistrant.register(with: 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
|
// Called when a notification is delivered while app is in foreground
|
||||||
@ -32,7 +24,7 @@ import Firebase
|
|||||||
completionHandler([.banner, .badge, .sound])
|
completionHandler([.banner, .badge, .sound])
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called when user taps a notification
|
// Called when user taps a notification (foreground or background)
|
||||||
override func userNotificationCenter(
|
override func userNotificationCenter(
|
||||||
_ center: UNUserNotificationCenter,
|
_ center: UNUserNotificationCenter,
|
||||||
didReceive response: UNNotificationResponse,
|
didReceive response: UNNotificationResponse,
|
||||||
|
|||||||
@ -1,8 +0,0 @@
|
|||||||
<?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,8 +43,13 @@ class LoginFormBloc extends Bloc<LoginFormEvent, LoginFormState> {
|
|||||||
|
|
||||||
if (emailValid && passwordValid) {
|
if (emailValid && passwordValid) {
|
||||||
// Ambil device info dan FCM token secara paralel
|
// Ambil device info dan FCM token secara paralel
|
||||||
final deviceInfo = await _deviceInfoService.getDeviceInfo();
|
final results = await Future.wait([
|
||||||
final fcmToken = await _fcmService.getToken();
|
_deviceInfoService.getDeviceInfo(),
|
||||||
|
_fcmService.getToken(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
final deviceInfo = results[0] as DeviceInfo;
|
||||||
|
final fcmToken = results[1] as String?;
|
||||||
|
|
||||||
failureOrAuth = await _repository.login(
|
failureOrAuth = await _repository.login(
|
||||||
email: state.email,
|
email: state.email,
|
||||||
|
|||||||
@ -194,15 +194,7 @@ class FcmService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the FCM registration token for this device.
|
/// Returns the FCM registration token for this device.
|
||||||
/// Returns null if token is unavailable (e.g. simulator, APNs not ready).
|
Future<String?> getToken() => _messaging.getToken();
|
||||||
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').
|
/// Subscribe to a topic (e.g. 'all', 'promo').
|
||||||
Future<void> subscribeToTopic(String topic) =>
|
Future<void> subscribeToTopic(String topic) =>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user