Friday, June 7, 2024
HomeiOS Developmentios - Why is the firebase message service not working?

ios – Why is the firebase message service not working?


My downside is that I do not obtain the push message despatched and I do not get an error after which I may begin and I do not know what I am doing improper.

It will be significant that I’m constructing a flutter software, the code runs with out errors and what I wished thus far works, however the push message doesn’t.
What I’ve finished thus far.

The libraries I take advantage of:
cupertino_icons: ^1.0.6 sign_in_with_apple: ^6.1.0 flutter_signin_button: ^2.0.0 webview_flutter: ^3.0.0 http: ^1.2.1 google_sign_in: ^6.2.1 firebase_core: ^3.0.0 firebase_auth: ^5.0.0 firebase_analytics: ^11.0.0 firebase_messaging: ^15.0.0 geolocator: ^12.0.0

the appliance accepts push messages. At Apple, I enabled all of the providers requested within the description.

What’s subsequent? How can I examine if there may be an error?

Thx

I begin firebase right here, it is very important notice that analytics is working, I can see it even when I’m lively on the firebase admin web page.

void predominant() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp(
    choices: DefaultFirebaseOptions.currentPlatform,
  );
  FirebaseAnalytics analytics = FirebaseAnalytics.occasion;
  await FirebaseNotifications().initNotifications();
  await FirebaseNotifications().setupInteractedMessage();

  runApp(const MyApp());
}

firebase_notification.dart file incorporates:

import 'bundle:firebase_messaging/firebase_messaging.dart';

Future<void> handleBackgroundMessage(RemoteMessage message) async {
  print('title: ${message.notification?.title}');
}

class FirebaseNotifications {
  remaining _firebaseMessaging = FirebaseMessaging.occasion;

  Future<void> initNotifications() async {
    await _firebaseMessaging.requestPermission();
    await FirebaseMessaging.occasion.requestPermission(provisional: true);

    String? token = await _firebaseMessaging.getToken();
    print('Token: $token');
    FirebaseMessaging.onBackgroundMessage(handleBackgroundMessage);
    remaining apnsToken = await FirebaseMessaging.occasion.getAPNSToken();
    if (apnsToken != null) {
      print('apns true');
    } else {
      print('apns false');
    }
  }

  Future<String?> getFirebaseToken() async {
    await _firebaseMessaging.requestPermission();
    String? token = await _firebaseMessaging.getToken();
    return token;
  }

  Future<void> setupInteractedMessage() async {
    RemoteMessage? initialMessage =
        await FirebaseMessaging.occasion.getInitialMessage();

    if (initialMessage != null) {
      handleMessage(initialMessage);
    }

    FirebaseMessaging.onMessageOpenedApp.hear(handleMessage);
  }

  void handleMessage(RemoteMessage? message) {
    if (message == null) return;
  }

  Future handleBackgroundNotification() async {
    FirebaseMessaging.occasion.getInitialMessage().then(handleMessage);
    FirebaseMessaging.onMessageOpenedApp.hear(handleMessage);
  }
}

The apn and token era additionally works.

AppDelegate.swift incorporates:

import UIKit
import Flutter
//import Firebase

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
  override func software(
    _ software: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
    GeneratedPluginRegistrant.register(with: self)
    //FirebaseApp.configure()
    return tremendous.software(software, didFinishLaunchingWithOptions: launchOptions)
  }
}

I do not use what I commented right here, so far as I do know it’s not crucial. However after I used it, I bought this error message: PlatformException (PlatformException(channel-error, Unable to determine connection on channel., null, null))



Supply hyperlink

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments