firebase remote config cancelled - failed on ios - 34 / 5.000 Çeviri sonuçları successful on android

Viewed 11

ERROR: firebase_remote_config cancelled

remote config works on android ✔️

remote config is wrong on ios ❌

ERROR: firebase_remote_config cancelled

ERROR LINE: await remoteConfig.fetchAndActivate();

my remote_config code for old version

await remoteConfig.fetch(expiration: Duration(seconds: 1));

await remoteConfig.activateFetched();

// Package imports:
import 'dart:async';
import 'dart:ui';
import 'package:firebase_core_platform_interface/firebase_core_platform_interface.dart';
import 'package:flutter/material.dart';
import 'package:connectivity/connectivity.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_remote_config/firebase_remote_config.dart';
import 'package:gedik_holding/core/controller/dashboard_controller.dart';
import 'package:gedik_holding/core/controller/login_controller.dart';
import 'package:gedik_holding/core/controller/odms_controller.dart';
import 'package:gedik_holding/core/controller/radio_controller.dart';
import 'package:gedik_holding/core/controller/vana_controller.dart';
import 'package:get/get.dart';
import 'package:get_storage/get_storage.dart';
import 'package:http/http.dart' as http;
import 'package:flutter/cupertino.dart';
import 'package:async/async.dart';

// Project imports:
import 'package:gedik_holding/core/controller/new_featured_products_controller.dart';
import 'package:gedik_holding/core/controller/story_slider_controller.dart';

class ConnectionController extends GetxController {
  var _connection = true.obs;
  var subscription;

  bool get getConnection => _connection.value;
  FirebaseRemoteConfig _remoteConfig = FirebaseRemoteConfig.instance; //remoteconfig --> firebase remote config oldu!

  FirebaseRemoteConfig get remoteConfig => _remoteConfig;
  AsyncMemoizer mainMemoizer = AsyncMemoizer();
  Connectivity connectivity = Connectivity();

  Future startConnection() async {
    print("connection controller started");

    connectivity.checkConnectivity().then((value) async {
      if (value == ConnectivityResult.none) {
        _showDialog(context: Get.context);
      } else {
        _remoteConfig = FirebaseRemoteConfig.instance;

        /*
    await remoteConfig.setConfigSettings(RemoteConfigSettings(
      fetchTimeout: const Duration(milliseconds: 15),
      minimumFetchInterval: Duration.zero,
    ));
    await remoteConfig.fetchAndActivate();
    */
        await remoteConfig.setConfigSettings(RemoteConfigSettings(
          fetchTimeout: const Duration(milliseconds: 15),
          minimumFetchInterval: Duration.zero,
        ));

        **//ERROR LINE** **//ERROR LINE** **//ERROR LINE** **//ERROR LINE**
        await remoteConfig.fetchAndActivate();

        // await remoteConfig.fetch(expiration: const Duration(milliseconds: 15));
        // await remoteConfig.activateFetched();
        await GetStorage.init();
        await Get.put(LoginController()).checkLogin();
        await Get.put(OdmsController()).getData();
        await Get.put(VanaController()).getData();
        await Get.put(StorySliderController()).sliderget();
        await Get.put(NewFeaturedProductsController()).productsget();
        await Get.put(ConnectionController()).connectionControl();
        await Get.put(RadioController()).liveMusicGet();
        await Get.put(DashboardController()).initDashboardController();
      }
    });
    subscription = connectivity.onConnectivityChanged
        .listen((ConnectivityResult result) async {
      if (result == ConnectivityResult.none) {
        _showDialog(context: Get.context);
      } else {
        _remoteConfig = FirebaseRemoteConfig.instance;

        await remoteConfig.setConfigSettings(RemoteConfigSettings(
          fetchTimeout: const Duration(milliseconds: 15),
          minimumFetchInterval: Duration.zero,
        ));

        **//ERROR LINE** **//ERROR LINE** **//ERROR LINE** **//ERROR LINE**
        await remoteConfig.fetchAndActivate();

        //await remoteConfig.fetch(expiration: const Duration(milliseconds: 15));
        //await remoteConfig.activateFetched();


        Get.back();
        // Navigator.of(Get.context).pop();
        Get.put(LoginController()).checkLogin();
        Get.put(OdmsController()).getData();
        Get.put(StorySliderController()).sliderget();
        Get.put(NewFeaturedProductsController()).productsget();
        Get.put(ConnectionController()).connectionControl();
        Get.put(RadioController()).liveMusicGet();
        Get.put(DashboardController()).initDashboardController();
      }
      print(result);
      //subscription.resume();
    });
  }

  Future connectionControl() async {
    await Get.put(StorySliderController()).sliderget();
    await Get.put(NewFeaturedProductsController()).productsget();
    await Firebase.initializeApp();
    _remoteConfig = FirebaseRemoteConfig.instance;

    await remoteConfig.setConfigSettings(RemoteConfigSettings(
      fetchTimeout: const Duration(milliseconds: 15),
      minimumFetchInterval: Duration.zero,
    ));

    **//ERROR LINE** **//ERROR LINE** **//ERROR LINE** **//ERROR LINE**
    await remoteConfig.fetchAndActivate();

    //await remoteConfig.fetch(expiration: const Duration(milliseconds: 15));
    //await remoteConfig.activateFetched();

    var url = "https://www.google.com.tr";
    http.Response response;
    try {
      response = await http.get(
        Uri.parse(url),
        headers: <String, String>{
          'Content-Type': 'application/json; charset=UTF-8',
        },
      );
      if (response.statusCode == 200 || response.statusCode == 301) {
        _connection.value = true;
        update();
      } else {
        _connection.value = false;
        update();
        Future.delayed(Duration(seconds: 1), () async {
          connectionControl();
          _remoteConfig = FirebaseRemoteConfig.instance;

          await remoteConfig.setConfigSettings(RemoteConfigSettings(
            fetchTimeout: const Duration(milliseconds: 15),
            minimumFetchInterval: Duration.zero,
          ));

          **//ERROR LINE** **//ERROR LINE** **//ERROR LINE** **//ERROR LINE**
          await remoteConfig.fetchAndActivate();

          //await remoteConfig.fetch(expiration: const Duration(milliseconds: 15));
          //await remoteConfig.activateFetched();


          await Firebase.initializeApp();
          await Get.put(StorySliderController()).sliderget();
          await Get.put(NewFeaturedProductsController()).productsget();
        });
      }
    } catch (e) {
      _connection.value = false;
      update();
      Future.delayed(Duration(seconds: 2), () {
        connectionControl();
        Get.put(StorySliderController()).sliderget();
        Get.put(NewFeaturedProductsController()).productsget();
      });
    }
    update();
  }

  _showDialog({BuildContext context}) {
    return Get.dialog(
      CupertinoAlertDialog(
        title: Text(
          'İnternet Bağlantınızı kontrol ediniz',
          style: TextStyle(fontWeight: FontWeight.w600),
        ),
        content: Container(
            margin: EdgeInsets.only(top: 16, bottom: 16),
            child: Center(
                child: Icon(
                    Icons.signal_cellular_connected_no_internet_4_bar_sharp))),
      ),
      barrierDismissible: false,
    );
  }
}
0 Answers
Related