Token retrieval failed: SERVICE_NOT_AVAILABLE. Will retry token retrieval
03:57 04 Mar 2024
void main() async{
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(
  options: DefaultFirebaseOptions.currentPlatform
);
final _firebaseMessaing = FirebaseMessaging.instance;
await _firebaseMessaing.requestPermission();

final fCMToken = await _firebaseMessaing.getToken();
print("This is token =========> ${fCMToken}");

runApp(MyApp());
}

Here I want the token but some errors occurs and the Token does not print. Not getting why I am facing this problem?

Unhandled Exception: [firebase_messaging/unknown] java.io.IOException: SERVICE_NOT_AVAILABLE

  E/flutter (17731): #0      StandardMethodCodec.decodeEnvelope 
(package:flutter/src/services/message_codecs.dart:651:7)
 E/flutter (17731): #1      MethodChannel._invokeMethod 
 (package:flutter/src/services/platform_channel.dart:322:18)
 E/flutter (17731): 
 E/flutter (17731): #2      MethodChannel.invokeMapMethod 
 (package:flutter/src/services/platform_channel.dart:522:43)
 E/flutter (17731): 
 E/flutter (17731): #3      MethodChannelFirebaseMessaging.getToken
android flutter firebase firebase-cloud-messaging