Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Foreground not working on ios #1733

Closed
elgammalqa opened this issue Dec 29, 2019 · 5 comments
Closed

Foreground not working on ios #1733

elgammalqa opened this issue Dec 29, 2019 · 5 comments
Labels
blocked: customer-response Waiting for customer response, e.g. more information was requested. type: bug Something isn't working

Comments

@elgammalqa
Copy link

elgammalqa commented Dec 29, 2019

my code
void main() {
  WidgetsFlutterBinding.ensureInitialized();
  final MyAuth myAuth = MyAuth();
  final APIManager apiManager = APIManager();

  myAuth.getMyData();
  apiManager.setInitialLanguage();

  runApp(
    MultiProvider(
      providers: [
        ChangeNotifierProvider(builder: (_) => apiManager),
        ChangeNotifierProvider(builder: (_) => apiManager.countryList),
        ChangeNotifierProvider(builder: (_) => myAuth),
      ],
      child: RestartWidget(
        child: MaterialApp(
          localizationsDelegates: [
            AppLocalizations.delegate,
            GlobalMaterialLocalizations.delegate,
            GlobalWidgetsLocalizations.delegate,
          ],
          supportedLocales: klanguages.map((lang) => Locale(lang)).toList(),
//          localeResolutionCallback: (locale, supportedLocales) {
          // Check if the current device locale is supported
//            for (var supportedLocale in supportedLocales) {
//              if (supportedLocale.languageCode == locale.languageCode &&
//                  supportedLocale.countryCode == locale.countryCode) {
//                return supportedLocale;
//              }
//            }
//
//            return supportedLocales.first;
//          },
          theme: ThemeData(
              backgroundColor: kbackgroundPrimaryColor,
              appBarTheme: AppBarTheme(
                color: kAppBarPrimaryColor,
              ),
              iconTheme: IconThemeData(
                color: kIconPrimaryColor,
              ),
              buttonTheme: ButtonThemeData(
                buttonColor: kIconPrimaryColor,
              ),
              fontFamily: 'jazeera'),
          routes: {
            '/': (_) => NewsBuzz(),
            '/1': (_) => CountryScreen(
                  savedNewSources: () {
                    apiManager.articles = null;
                    apiManager.getArticles(page: 1, user: myAuth.user);
                  },
                ),
            '/2': (_) => MySourcesScreen(),
            '/3': (_) => LoginSignUpPage(
                  onSignedIn: () {
                    apiManager.getCountries(myAuth.user);
                    apiManager.getArticles(page: 1, user: myAuth.user);
                  },
                ),
            '/4': (_) => CategoriesScreen(),
            '/comments': (_) => CommentsScreen(),
            '/webview': (_) => WebViewScreen(),
            '/homeFees': (_) => HomeFeedScreen(),
            '/replyright': (_) => ReplyRightsScreen(),
            '/addreplyright': (_) => AddReplyRightScreen(),
            '/mailcomposer': (_) => MailComposerScreen(),
            '/news': (_) => NewsScreen(),
          },
          initialRoute: '/',
        ),
      ),
    ),
  );
}

class NewsBuzz extends StatefulWidget {
  @override
  createState() => new NewsBuzzState();
}

class NewsBuzzState extends State<NewsBuzz>
    with SingleTickerProviderStateMixin {
  final FirebaseMessaging _firebaseMessaging = FirebaseMessaging();
  setupNotifs() {
    _firebaseMessaging
        .requestNotificationPermissions(IosNotificationSettings());

    _firebaseMessaging.configure(onMessage: (Map<String, dynamic> msg) {
      print('ON MESSAGE ---');

      print(msg);
      dynamic notif = msg['notification'];
      print(notif);
      dynamic myData = notif['data'] ?? msg;

      print(myData + '========================================');

      dynamic link = myData.toString().split(':');
      String id = link.last;
      String url = link[1] + link[2];
      String lang = link[4];
      url = url.replaceAll(r'\', r'');
      url = url.split('"')[1];
      id = id.split('"')[1];
      lang = lang.split('"')[1];
      print(url + '0-0-0-0-0--0-0-0-0-0-0-0-0' + id + 'xxxxxxxxx' + lang);
      return null;
    }, onResume: (Map<String, dynamic> msg) async {
      print('ON RESUME --------');
      print(msg);
      dynamic myData = msg['gcm.notification.data'];
//      print(notif);
//      dynamic myData = notif['data'] ?? msg;

      print(myData + '========================================');

      dynamic link = myData.toString().split(':');
      String id = link.last;
      String url = link[1] + link[2];
      String lang = link[4];
      url = url.replaceAll(r'\', r'');
      url = url.split('"')[1];
      id = id.split('"')[1];
      lang = lang.split('"')[1];
      print(url + '0-0-0-0-0--0-0-0-0-0-0-0-0' + id);

      Navigator.pushNamed(context, '/webview', arguments: '$id/$lang');
      return null;
    }, onLaunch: (Map<String, dynamic> msg) async {
      print('ON LAUNCH ----------');
      print(msg);
      dynamic notif = msg['notification'];
      print(notif);
      dynamic myData = notif['data'] ?? msg;

      print(myData + '========================================');

      dynamic link = myData.toString().split(':');
      String id = link.last;
      String url = link[1] + link[2];
      String lang = link[4];
      url = url.replaceAll(r'\', r'');
      url = url.split('"')[1];
      id = id.split('"')[1];
      lang = lang.split('"')[1];
      print(url + '0-0-0-0-0--0-0-0-0-0-0-0-0' + id);

      Navigator.pushNamed(context, '/webview', arguments: '$id/$lang');
      return null;
    });
//    _firebaseMessaging.subscribeToTopic('test1');
//    _firebaseMessaging.subscribeToTopic('en-United__Kingdom-reuters');
//    _firebaseMessaging.subscribeToTopic('en-United__Kingdom-independent');
//    _firebaseMessaging.subscribeToTopic('en-United__Kingdom-standard');
//    _firebaseMessaging.subscribeToTopic('en-United__Kingdom-wales__online');
//    _firebaseMessaging.subscribeToTopic('en-United__States-wired');
//    _firebaseMessaging.subscribeToTopic('en-United__States-abc7');
//    _firebaseMessaging.subscribeToTopic('en-United__States-slate');
//    _firebaseMessaging.subscribeToTopic('en-United__States-info__world');
//    print(
//        'SUBSCRIBED TO NEW TESTING ======================++++++++++++++++++++++++++++++++++++');
//    String fcmToken = await _firebaseMessaging.getToken();
//    print(fcmToken);
  }

  @override
  Widget build(BuildContext context) {
    setupNotifs();
    return HomeFeedScreen();
  }
}

Flutter doctor :

[✓] Flutter (Channel master, v1.13.6-pre.39, on Mac OS X 10.14.6 18G95, locale en-EG)
[✗] Android toolchain - develop for Android devices
    ✗ Unable to locate Android SDK.
      Install Android Studio from: https://developer.android.com/studio/index.html
      On first launch it will assist you in installing the Android SDK components.
      (or visit https://flutter.dev/setup/#android-setup for detailed instructions).
      If the Android SDK has been installed to a custom location, set ANDROID_HOME to that location.
      You may also want to add it to your PATH environment variable.

[✓] Xcode - develop for iOS and macOS (Xcode 11.2.1)
[!] Android Studio (not installed)
[!] IntelliJ IDEA Community Edition (version 2019.2.4)
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
[✓] Connected device (2 available)

! Doctor found issues in 3 categories.
@elgammalqa elgammalqa added the type: bug Something isn't working label Dec 29, 2019
@iapicca
Copy link

iapicca commented Dec 31, 2019

Hi @elgammalqa
can you please provide your flutter run --verbose?
Thank you

@iapicca iapicca added the blocked: customer-response Waiting for customer response, e.g. more information was requested. label Dec 31, 2019
@ziasultan2
Copy link

Hi I'm also facing same problem in iOS 10.3 but it doesn't show or print anything in foreground.
Here is my verbose
Zia-Sultan:user-master Raymond$ flutter run --verbose
[ +29 ms] executing: [/Users/johnsmith/Developer/flutter/] git log -n 1
--pretty=format:%H
[ +61 ms] Exit code 0 from: git log -n 1 --pretty=format:%H
[ ] cc949a8e8b9cf394b9290a8e80f87af3e207dce5
[ ] executing: [/Users/johnsmith/Developer/flutter/] git describe --match
v*.. --first-parent --long --tags
[ +34 ms] Exit code 0 from: git describe --match v*.. --first-parent --long
--tags
[ ] v1.9.1+hotfix.4-0-gcc949a8e8
[ +11 ms] executing: [/Users/johnsmith/Developer/flutter/] git rev-parse
--abbrev-ref --symbolic @{u}
[ +8 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic @{u}
[ ] origin/stable
[ ] executing: [/Users/johnsmith/Developer/flutter/] git ls-remote
--get-url origin
[ +7 ms] Exit code 0 from: git ls-remote --get-url origin
[ ] https://github.com/flutter/flutter.git
[ +62 ms] executing: [/Users/johnsmith/Developer/flutter/] git rev-parse
--abbrev-ref HEAD
[ +8 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD
[ ] stable
[ +416 ms] executing: /Users/Raymond
Tucker/Library/Android/sdk/platform-tools/adb devices -l
[ +11 ms] Exit code 0 from: /Users/Raymond
Tucker/Library/Android/sdk/platform-tools/adb devices -l
[ ] List of devices attached
[ +12 ms] executing:
/Users/johnsmith/Developer/flutter/bin/cache/artifacts/libimobiledevice/idevice_
id -h
[ +393 ms] /usr/bin/xcrun simctl list --json devices
[ +261 ms] More than one device connected; please specify a device with the '-d
'
flag, or use '-d all' to act on all devices.
[ +9 ms] MacBook’s iPhone • be947003ab8eb9f9faf0f676f538e779f5d09e96 • ios •
iOS 10.3.4
[ +2 ms] iPhone 11 • 73389C55-71B6-4957-8EE1-A27248A7CF58 • ios •
com.apple.CoreSimulator.SimRuntime.iOS-13-1 (simulator)
[ +16 ms] "flutter run" took 1,128ms.

#0 throwToolExit (package:flutter_tools/src/base/common.dart:28:3)
#1 RunCommand.validateCommand
(package:flutter_tools/src/commands/run.dart:281:7)

#2 FlutterCommand.verifyThenRunCommand
(package:flutter_tools/src/runner/flutter_command.dart:465:11)

#3 FlutterCommand.run.
(package:flutter_tools/src/runner/flutter_command.dart:407:33)

#4 AppContext.run.
(package:flutter_tools/src/base/context.dart:154:29)

#5 _rootRun (dart:async/zone.dart:1124:13)
#6 _CustomZone.run (dart:async/zone.dart:1021:19)
#7 _runZoned (dart:async/zone.dart:1516:10)
#8 runZoned (dart:async/zone.dart:1463:12)
#9 AppContext.run (package:flutter_tools/src/base/context.dart:153:18)

#10 FlutterCommand.run
(package:flutter_tools/src/runner/flutter_command.dart:397:20)
#11 CommandRunner.runCommand (package:args/command_runner.dart:197:27)

#12 FlutterCommandRunner.runCommand.
(package:flutter_tools/src/runner/flutter_command_runner.dart:402:21)

#13 AppContext.run.
(package:flutter_tools/src/base/context.dart:154:29)

#14 _rootRun (dart:async/zone.dart:1124:13)
#15 _CustomZone.run (dart:async/zone.dart:1021:19)
#16 _runZoned (dart:async/zone.dart:1516:10)
#17 runZoned (dart:async/zone.dart:1463:12)
#18 AppContext.run (package:flutter_tools/src/base/context.dart:153:18)

#19 FlutterCommandRunner.runCommand
(package:flutter_tools/src/runner/flutter_command_runner.dart:356:19)

#20 CommandRunner.run.
(package:args/command_runner.dart:112:25)
#21 new Future.sync (dart:async/future.dart:224:31)
#22 CommandRunner.run (package:args/command_runner.dart:112:14)
#23 FlutterCommandRunner.run
(package:flutter_tools/src/runner/flutter_command_runner.dart:242:18)
#24 run..
(package:flutter_tools/runner.dart:63:22)

#25 _rootRun (dart:async/zone.dart:1124:13)
#26 _CustomZone.run (dart:async/zone.dart:1021:19)
#27 _runZoned (dart:async/zone.dart:1516:10)
#28 runZoned (dart:async/zone.dart:1500:12)
#29 run. (package:flutter_tools/runner.dart:61:18)

#30 AppContext.run.
(package:flutter_tools/src/base/context.dart:154:29)

#31 _rootRun (dart:async/zone.dart:1124:13)
#32 _CustomZone.run (dart:async/zone.dart:1021:19)
#33 _runZoned (dart:async/zone.dart:1516:10)
#34 runZoned (dart:async/zone.dart:1463:12)
#35 AppContext.run (package:flutter_tools/src/base/context.dart:153:18)

#36 runInContext (package:flutter_tools/src/context_runner.dart:59:24)

#37 run (package:flutter_tools/runner.dart:50:10)
#38 main (package:flutter_tools/executable.dart:65:9)

#39 main
(file:///b/s/w/ir/k/archive/flutter/packages/flutter_tools/bin/flutter_tools.dar
t:8:3)
#40 _startIsolate.
(dart:isolate-patch/isolate_patch.dart:303:32)
#41 _RawReceivePortImpl._handleMessage
(dart:isolate-patch/isolate_patch.dart:172:12)

Hope you can give me a solution ASAP

@elgammalqa
Copy link
Author

Hi @iapicca
This my flutter run --verbose

flutterrunverbose.txt

@elgammalqa
Copy link
Author

@iapicca Any update?

@iapicca
Copy link

iapicca commented Jan 21, 2020

Hi @elgammalqa
I see there's an open issue addressing the case you described.
Please follow up on that issue,
I'm closing the current one as duplicate.
If you disagree please write in the comments
and I will reopen it.
Thank you

@iapicca iapicca closed this as completed Jan 21, 2020
@firebase firebase locked and limited conversation to collaborators Aug 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
blocked: customer-response Waiting for customer response, e.g. more information was requested. type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants