Closed
Description
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.