본문 바로가기
개발/Flutter web

flutter web firebase dynamic link 관련 오류

by dev_caleb 2022. 10. 22.
728x90

Error: MissingPluginException(No implementation found for method FirebaseDynamicLinks#getInitialLink on channel plugins.flutter.io/firebase_dynamic_links)
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 266:49  throw_
packages/flutter/src/services/platform_channel.dart 294:7                     _invokeMethod
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 45:50            <fn>
dart-sdk/lib/async/zone.dart 1653:54                                          runUnary
dart-sdk/lib/async/future_impl.dart 147:18                                    handleValue
dart-sdk/lib/async/future_impl.dart 766:44                                    handleValueCallback
dart-sdk/lib/async/future_impl.dart 795:13                                    _propagateToListeners
dart-sdk/lib/async/future_impl.dart 566:5                                     [_completeWithValue]
dart-sdk/lib/async/future_impl.dart 639:7                                     callback
dart-sdk/lib/async/schedule_microtask.dart 40:11                              _microtaskLoop
dart-sdk/lib/async/schedule_microtask.dart 49:5                               _startMicrotaskLoop
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 166:15           <fn>
Error: [firebase_messaging/failed-service-worker-registration] Messaging: We are unable to register the default service worker. Failed to register a ServiceWorker for scope ('http://localhost:5000/firebase-cloud-messaging-push-scope') with script ('http://localhost:5000/firebase-messaging-sw.js'): The script has an unsupported MIME type ('text/html'). .
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 299:10  createErrorWithStack
dart-sdk/lib/_internal/js_dev_runtime/patch/core_patch.dart 341:28            _throw
dart-sdk/lib/core/errors.dart 116:5                                           throwWithStackTrace
dart-sdk/lib/async/zone.dart 1378:11                                          callback
dart-sdk/lib/async/schedule_microtask.dart 40:11                              _microtaskLoop
dart-sdk/lib/async/schedule_microtask.dart 49:5                               _startMicrotaskLoop
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 166:15           <fn>

 

ㅜ_ㅜ flutter web 사용하는 건 정말 어려운 일이야~

 

해결법 1

https://github.com/firebase/flutterfire/issues/4378

 

🐛 [firebase_dynamic_links] No implementation found for method FirebaseDynamicLinks#getInitialLink · Issue #4378 · firebase/

Bug report Describe the bug When launching my app, I constantly get errors saying that MissingPluginException(No implementation found for method FirebaseDynamicLinks#getInitialLink on channel plugi...

github.com

firebase 는 dynamic link를 지원하지 않는다.

 

if(!kIsWeb) {
  initDynamicLinks();
}

..

이래도 안되네.. 지치는 것도 지쳤어

 

Future<void> initFirebase() async {
  // MobileAds.instance.initialize();  ///나중에 하자!
  // FCM
  if (!kIsWeb) {
    FirebaseMessaging.onMessage.listen((message) async {
      // TODO: push notification widget
      if (message.notification != null) {
        final box = GetStorage();
      }
    });
    FirebaseMessaging.onBackgroundMessage(
        _firebaseMessagingBackgroundHandler);
  }
  await Firebase.initializeApp(
    options: DefaultFirebaseOptions.currentPlatform,
  );
  if (!kIsWeb) {
    initDynamicLinks();
  }
  if (!kIsWeb) {
    await FirebaseMessaging.instance.requestPermission(
      alert: true,
      badge: true,
      sound: true,
      announcement: false,
      carPlay: false,
      criticalAlert: false,
      provisional: false,
    );
  }
}

메시지 관련 부분을 다 가렸더니, build 성공 , 야호~~!

728x90