import 'dart:io';

import 'package:firebase_messaging/firebase_messaging.dart';

abstract class IFirebaseService {
  Future<String> getFirebaseToke();
}

class FirebaseService implements IFirebaseService {
  final FirebaseMessaging? _firebaseMessaging = FirebaseMessaging.instance;

  FirebaseService() {
    _firebaseMessaging!.setAutoInitEnabled(true);
    if (Platform.isIOS) {
      _firebaseMessaging!.requestPermission();
    }
  }

  @override
  Future<String> getFirebaseToke() async {
    var token = await _firebaseMessaging!.getToken();
    return token ?? "";
  }
}
