Firebase Storage flutter uploadTask.onComplete crashes ios app - ios

i have flutter app setup with firestore, fcm and firebase cloud storge which works great on android, and on ios i have added GoogleService-Info.plist to Runner from xcode and also called await Firebase.initializeApp(); on my main.dart on android firestore and storage works good i am able to CRUD data, upload files but when i try to upload media on to firebase on
ios with this code
Future uploadFile(int index, int type) async {
String fileName =
DateTime.now().millisecondsSinceEpoch.toString() + "${widget.userId}";
StorageReference reference = FirebaseStorage.instance.ref().child(fileName);
StorageUploadTask uploadTask = reference.putFile(File(images[index]));
StorageTaskSnapshot storageTaskSnapshot = await uploadTask.onComplete;
storageTaskSnapshot.ref.getDownloadURL().then((downloadUrl) {
setState(() {
isLoading = false;
imageUrl = downloadUrl;
});
}, onError: (err) {
setState(() {
isLoading = false;
});
});
}
the ios app crashes abnormally nothing is being printed on the console when run normally
but when run on verbose mode i see this logged
[+123976 ms] Service protocol connection closed.
[ +1 ms] Lost connection to device.
[ +35 ms] DevFS: Deleting filesystem on the device
(file:///Users/Me/Library/Developer/CoreSimulator/Devices/12E19722-CC83-452B-B263-EF624D069BED/dat
a/Containers/Data/Application/BC48EA57-B913-4281-9628-59C783B0FE77/tmp/r2a_mobile28vRsI/r2a_mobile/)
[ +258 ms] Ignored error while cleaning up DevFS: TimeoutException after 0:00:00.250000: Future not
completed
[ +4 ms] "flutter run" took 223,298ms.
[ +271 ms] ensureAnalyticsSent: 264ms
[ +2 ms] Running shutdown hooks
[ ] Shutdown hook priority 4
[ +7 ms] Shutdown hooks complete
[ +2 ms] exiting with code 0
have also added <key>CFBundleURLSchemes</key> on to my info.plist with my REVERSED_CLIENT_ID from google plist
Firebase Packages on pubspec:
firebase_core: ^0.5.0
cloud_firestore: ^0.14.0+2
firebase_storage: ^4.0.0
firebase_messaging: ^7.0.0
Flutter Version:
Flutter 1.20.2 • channel stable • https://github.com/flutter/flutter.git
Framework • revision bbfbf1770c (10 days ago) • 2020-08-13 08:33:09 -0700
Engine • revision 9d5b21729f
Tools • Dart 2.9.1
i really need some help here
Thanks in Advance

Related

FCM Token for firebase cloud messaging sometimes not registered

I have a React Native app with React Native Firebase, which I use for push notifications / cloud messaging.
So generally everything is fine, but the iOS version has one issue.
The problem is that the FCM Token I receive (const fcmToken = await messaging().getToken()) sometimes is valid and works and sometimes I get an error with NotRegistered as reason.
My test is very simple. I uploaded a version to TestFlight. When I'm now installing this version of the app a few times then the received FCM token is sometimes valid and sometimes it is not.
The same code, the same keys/certificates, the same device.
Additionally checking the APNS token, that seems to be valid and working fine every time I checked.
I made sure I setup the Firebase app on launch with [FIRApp configure];
I checked if the App is registered at the APNS
I checked on another iPhone (The result was the same)
What can possible be wrong when the token sometimes works and sometimes doesn't?
Any hints are highly appreciated 🙏
System info:
System:
OS: macOS 10.15.6
CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU # 2.80GHz
Memory: 557.23 MB / 16.00 GB
Shell: 3.0.2 - /usr/local/bin/fish
Binaries:
Node: 14.5.0 - /var/folders/bn/f6trf3q55vj_hjplf9vy9ls00000gn/T/yarn--1598005931689-0.20174739828176125/node
Yarn: 1.22.4 - /var/folders/bn/f6trf3q55vj_hjplf9vy9ls00000gn/T/yarn--1598005931689-0.20174739828176125/yarn
npm: 6.14.5 - ~/.nodenv/shims/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 13.6, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2
Android SDK:
API Levels: 28, 29
Build Tools: 28.0.3, 29.0.2
System Images: android-28 | Intel x86 Atom, android-28 | Google APIs Intel x86 Atom, android-28 | Google Play Intel x86 Atom
Android NDK: Not Found
IDEs:
Android Studio: 3.6 AI-192.7142.36.36.6392135
Xcode: 11.6/11E708 - /usr/bin/xcodebuild
Languages:
Java: 1.8.0_232 - /usr/bin/javac
Python: 2.7.16 - /usr/bin/python
npmPackages:
#react-native-community/cli: Not Found
react: 16.13.1 => 16.13.1
react-native: 0.63.2 => 0.63.2
npmGlobalPackages:
*react-native*: Not Found
fcm sends a NotRegistered state because if you turn off the app based on ios, the fcm and the app's state are disconnected.
So, when you get the token value by executing the getToken function, you get the old token value instead of getting a new refresh token.
So, if you execute the following code and perform post message again with the refresh token value, you can receive the message normally.
const getToken = async () => {
const oldToken = await messaging().getToken();
await messaging().deleteToken(String(${fcm_send_id}), '*');
const newToken = await messaging().getToken();
if (oldToken === newToken) {
console.log('not refresh')
} else {
return newToken;
}
};

Flutter (web) Provider not working in released mode, but working in debug

I'm experiencing some odd behavior where a Provider behaves differently in debug vs. release mode.
This question is posted in off this question.
Here is a short description of the functionality: I have a list of ExpansionTiles (containing TextFormFields in their body) and a FloatingActionButton that adds to the list of ExpansionTiles. Below those two widgets I have one Back button and one Next button. The Next button needs be "unavailable" (ie. throw an error message to the user and have the color grey) as long as any TextFormField in the list of ExpansionTiles is incomplete. Once all TextFormFields are ready the Next button should change color and direct the user to a new page. Changing the color and functionality works fine in debug, but not in release mode (ie. after running: flutter build web).
Firstly: TravelProceedModel monitors the status of whether the user can click the Next button or not. Ie. this is just a simple bool. Whenever updateCanProceed() is called I update canProceed and also notifyListeners().
import 'package:flutter/material.dart';
class TravelProceedModel extends ChangeNotifier {
bool canProceed;
void updateCanProceed(bool value) {
canProceed = value;
notifyListeners();
}
}
Secondly, the TravelProceedModel is implemented using the ChangeNotifierProvider and then using Consumer. I'm expecting (and this works in debug) that when canProceed is changed this line: "nextEnabled: proceedModel.canProceed" should cause the button the change color. However, this only works in debug mode.
class TravelDeductionTrips extends StatefulWidget {
#override
_TravelDeductionTripsState createState() => _TravelDeductionTripsState();
}
class _TravelDeductionTripsState extends State<TravelDeductionTrips> {
#override
Widget build(BuildContext context) {
String year = Provider.of<UserSelectionsModel>.(context).selected_report["year"];
String report = Provider.of<UserSelectionsModel>(context).selected_report["report"];
return MultiProvider(
providers: [
ChangeNotifierProvider(
create: (context) => TravelProceedModel()
),
ChangeNotifierProvider(
create: (context) => TravelModel(
year: year,
report: report,
),
),
],
child: Consumer<TravelModel>(
builder: (context, travelModel, child) {
return FutureBuilder(
future: travelModel.fetchTripsToLocalSession(),
builder: (context, data) {
if (data.connectionState == ConnectionState.done) {
return Column(
children: <Widget>[
TravelDeductionTripList(),
Consumer<TravelProceedModel>(
builder: (context, proceedModel, child) {
proceedModel.updateCanProceed(
travelModel.checkProceedCondition()
);
return BackNextButtons(
backEnabled: true,
nextEnabled: proceedModel.canProceed,
backText: "Tilbage",
nextText: travelModel.trips["next_action_title"],
errorMessage: travelModel.proceedErrorMessage,
nextFunction: () async {
await addQuestionIDtoStack(year, report, travelModel.trips["next_question_id"], true);
}, // No special function is needed, this is just a simple next
);
},
),
],
);
} else {
return Center(
child: CircularProgressIndicator(),
);
}
}
);
}
),
);
}
}
NB! proceedModel.canProceed is updated from within TravelDeductionTripList() which calls
Provider.of<TravelProceedModel>(context, listen: false).updateCanProceed(
Provider.of<TravelModel>(context, listen: false).checkProceedCondition()
);
The Next button only changes colors after reloading the widget. Ie. it appears that the TravelProceedModel is being updated but that the widget is not being redrawn in the UI - although it happens perfectly in debug mode.
Does anybody have any idea why debug works but release does not?
Below is my "flutter doctor -v". Notice, that this is a flutter web project.
[✓] Flutter (Channel beta, v1.15.17, on Mac OS X 10.15.2 19C57, locale en-US)
• Flutter version 1.15.17 at /Users/danni/Documents/flutter/flutter
• Framework revision 2294d75bfa (13 days ago), 2020-03-07 00:28:38 +0900
• Engine revision 5aff311948
• Dart version 2.8.0 (build 2.8.0-dev.12.0 9983424a3c)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at /Users/danni/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-29, build-tools 29.0.2
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
• All Android licenses accepted.
[✗] Xcode - develop for iOS and macOS
✗ Xcode installation is incomplete; a full installation is necessary for iOS development.
Download at: https://developer.apple.com/xcode/download/
Or install Xcode via the App Store.
Once installed, run:
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
sudo xcodebuild -runFirstLaunch
✗ CocoaPods installed but not working.
You appear to have CocoaPods installed but it is not working.
This can happen if the version of Ruby that CocoaPods was installed with is different from the one being used
to invoke it.
This can usually be fixed by re-installing CocoaPods. For more info, see
https://github.com/flutter/flutter/issues/14293.
To re-install CocoaPods, run:
sudo gem install cocoapods
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 3.5)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 41.0.2
• Dart plugin version 191.8593
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
[✓] VS Code (version 1.43.0)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.8.1
[✓] Connected device (2 available)
• Chrome • chrome • web-javascript • Google Chrome 80.0.3987.149
• Web Server • web-server • web-javascript • Flutter Tools
! Doctor found issues in 1 category.
I had the same problem, and I've made a workaround for it.
Since listen is a parameter, you can pass any other bool variable to it (should not be a constant true or false).
There is a built-in bool variable in foundation.dart package called kReleaseMode.
So here is an example, how i handled this listener problem between debug and release mode:
await Provider.of<AuthService>(context, listen: kReleaseMode).loginUser(
user: _username, password: _password);
For me, it works perfectly.

Why is Deep Link Web URL query is empty

Using Flutter and Firebase dynamic links, I am able to create a link. When it is clicked it opens the app but there is no link data, and no callbacks that a link was clicked is fired. Instead in the Xcode logs I get Deep Link Web URL query is empty Link is copied from the app into Notes, then clicked. Is there anything that I am missing, or what else can I check to get this working?
Firebase Deep Link Web URL query is empty - iOS
Checked this relevant post, but installing the required pod dependencies is not the solution as you can see below in the pod install logs.
Flutter Doctor
[✓] Flutter (Channel stable, v1.12.13+hotfix.8, on Mac OS X 10.15 19A582a, locale en-US)
[!] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
✗ Android license status unknown.
Try re-installing or updating your Android SDK Manager.
See https://developer.android.com/studio/#downloads or visit https://flutter.dev/setup/#android-setup for detailed
instructions.
[✓] Xcode - develop for iOS and macOS (Xcode 11.2.1)
[✓] Android Studio (version 3.5)
[✓] Android Studio (version 3.5)
[✓] IntelliJ IDEA Ultimate Edition (version 2019.1.4)
[!] IntelliJ IDEA Community Edition (version 2019.1.3)
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
[✓] VS Code (version 1.43.0)
[✓] Connected device (1 available)
! Doctor found issues in 2 categories.
Xcode logs
---- Firebase Dynamic Links diagnostic output start ----
Firebase Dynamic Links framework version 4.0.7
System information: OS iOS, OS version 13.3.1, model iPhone
Current date 2020-03-10 12:46:34 +0000
Device locale en-US (raw en_US), timezone America/Boise
Specified custom URL scheme is com.pitch.links and Info.plist contains such scheme in CFBundleURLTypes key.
AppID Prefix: XXXXXXXXXX, Team ID: XXXXXXXXXX, AppId Prefix equal to Team ID: YES
performDiagnostic completed successfully! No errors found.
---- Firebase Dynamic Links diagnostic output end ----
Runner[366:14705] 6.18.0 - [Firebase/Analytics][I-ACS800023] No pending snapshot to activate. SDK name: app_measurement
Runner[366:14754] 6.18.0 - [Firebase/Analytics][I-ACS800003] Registered an SDK that has already registered. Default flags will be overwritten. SDK name: app_measurement
Runner[366:14754] 6.18.0 - [Firebase/Analytics][I-ACS800023] No pending snapshot to activate. SDK name: app_measurement
Runner[366:14712] Connection 3: received failure notification
Runner[366:14712] Connection 3: failed to connect 12:8, reason -1
Runner[366:14712] Connection 3: encountered error(12:8)
Runner[366:14712] Task <03A1535D-FD13-4872-B14B-6673E202F028>.<2> HTTP load failed, 0/0 bytes (error code: -1003 [12:8])
Runner[366:14712] Task <03A1535D-FD13-4872-B14B-6673E202F028>.<2> finished with error [-1003] Error Domain=NSURLErrorDomain Code=-1003 "A server with the specified hostname could not be found." UserInfo={NSUnderlyingError=0x282e21b30 {Error Domain=kCFErrorDomainCFNetwork Code=-1003 "(null)" UserInfo={_kCFStreamErrorCodeKey=8, _kCFStreamErrorDomainKey=12}}, NSErrorFailingURLStringKey=https://firebasedynamiclinks-ipv6.googleapis.com/v1/installAttribution?key= AIzaxxxxxxx_xxxxxxxxxx_xxxxxxxxxxxxxxxx, NSErrorFailingURLKey=https://firebasedynamiclinks-ipv6.googleapis.com/v1/installAttribution?key= AIzaxxxxxxx_xxxxxxxxxx_xxxxxxxxxxxxxxxx, _kCFStreamErrorDomainKey=12, _kCFStreamErrorCodeKey=8, NSLocalizedDescription=A server with the specified hostname could not be found.}
Runner[366:14505] [ProcessSuspension] 0x10e4e13b0 - ProcessAssertion::processAssertionWasInvalidated()
Runner[366:14505] [ProcessSuspension] 0x10e4e1410 - ProcessAssertion::processAssertionWasInvalidated()
Runner[366:14707] 6.18.0 - [Firebase/Analytics][I-ACS023012] Analytics collection enabled
Runner[366:14707] 6.18.0 - [Firebase/Analytics][I-ACS023001] Deep Link does not contain valid required params. URL params: {
dismiss = 1;
"is_weak_match" = 1;
}
Runner[366:14505] Could not signal service com.apple.WebKit.WebContent: 113: Could not find specified service
Runner[366:14505] Could not signal service com.apple.WebKit.Networking: 113: Could not find specified service
Runner[366:14505] Returning local object of class NSString
Runner[366:14505] Can't end BackgroundTask: no background task exists with identifier 14 (0xe), or it may have already been ended. Break in UIApplicationEndBackgroundTaskError() to debug.
Runner[366:15138] 6.18.0 - [Firebase/Analytics][I-ACS023000] Deep Link Web URL query is empty
apple-app-site-association
{"applinks":{"apps":[],"details":[{"appID":"XXXXXXXXXX.com.pitch.links","paths":["NOT /_/*","/*"]}]}}
applinks:pitchlink.page.link is listed as an Associated Domain
and URL Type with Identifier of Bundle ID and URL Schemes com.pitch.links has been added to the Info.plist
Flutter main.dart
import 'package:firebase_dynamic_links/firebase_dynamic_links.dart';
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
#override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Dynamic Links',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Dynamic Links'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
#override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
Uri dynamicUrl;
#override
void initState() {
super.initState();
this.initDynamicLinks();
}
void initDynamicLinks() async {
final DynamicLinkParameters parameters = DynamicLinkParameters(
uriPrefix: 'https://pitchlink.page.link',
link: Uri.parse('https://example.com/suffix?d=1'),
iosParameters: IosParameters(
bundleId: 'com.pitch.links',
minimumVersion: '0.0.1',
),
);
FirebaseDynamicLinks.instance.onLink(
onSuccess: (PendingDynamicLinkData dynamicLink) async {
final Uri deepLink = dynamicLink?.link;
print(deepLink.toString());
}, onError: (OnLinkErrorException e) async {
print('onLinkError');
print(e.message);
});
ShortDynamicLink link = await parameters.buildShortLink();
setState(() {
dynamicUrl = link.shortUrl;
});
}
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'Dynamic Link:',
),
dynamicUrl != null
? SelectableText(
dynamicUrl.toString(),
)
: Container(),
],
),
),
);
}
}
pubspec.yaml
name: pitch_links
description: A new Flutter project.
version: 0.0.0+1
environment:
sdk: ">=2.1.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
firebase_dynamic_links: ^0.5.0+11
firebase_analytics: ^5.0.11
cupertino_icons: ^0.1.2
dev_dependencies:
flutter_test:
sdk: flutter
flutter:
uses-material-design: true
pod install --clean-install --verbose
-> Using Firebase (6.18.0)
-> Using FirebaseAnalytics (6.3.0)
-> Using FirebaseAnalyticsInterop (1.5.0)
-> Using FirebaseCore (6.6.3)
-> Using FirebaseCoreDiagnostics (1.2.1)
-> Using FirebaseCoreDiagnosticsInterop (1.2.0)
-> Using FirebaseDynamicLinks (4.0.7)
-> Using FirebaseInstallations (1.1.0)
-> Using Flutter (1.0.0)
-> Using GoogleAppMeasurement (6.3.0)
-> Using GoogleDataTransport (4.0.1)
-> Using GoogleDataTransportCCTSupport (1.4.1)
-> Using GoogleUtilities (6.5.1)
-> Using PromisesObjC (1.2.8)
-> Using firebase_analytics (0.0.1)
-> Using firebase_dynamic_links (0.1.0)
-> Using nanopb (0.3.9011)
The solution that worked to fix my issue was to call await FirebaseDynamicLinks.instance.getInitialLink(); within initDynamicLinks() The same errors still appear in the Xcode logs, but I am able to parse out the link data.

network type not getting in iOS using Ionic native

We are developing an ionic native mobile application. we need network type (wifi,2g,3g,4g).We are getting in android but unable to get in iOS.We tried those commands for network plugins
$ ionic cordova plugin add cordova-plugin-network-information
$ npm install --save #ionic-native/network
Code
this.platform.ready().then(() => {
setTimeout(() => {
var networkState = this.network.type;
alert("networktype"+JSON.stringify(this.network));
console.log("networktype"+JSON.stringify(this.network));
}, 30000);
});
Always we are getting null in iOS. guide to us what we miss
iOS version :10.3.3
ionic info :

user code-push on iOS platform , prompt code-push is undefined, and can not call apis of code-push service

I need use code-push service in react-native on iOS platform. Version is 1.17.3-beta.
Local already deployed code-push service. then run the command line to import code-push plug-in.
As shown below.
npm install --save react-native-code-push
react-native link react-native-code-push
Loading code-push module in js.
import codePush from 'react-native-code-push'
There is a problem. prompt codePush is undefined. And I can not call apis for example checkForUpdate() sync().
componentDidMount(){
AppState.addEventListener("change", (newState) => {
newState === "active" && codePush.sync();
});
},
The documents of code-push can be found in node_modules directory,but why not be identified ?
Can any one help please ? Thanks.
Are you sure codePush is undefined?
Try this:
...
const codePushOptions = { checkFrequency: codePush.CheckFrequency.ON_APP_RESUME };
App = codePush(codePushOptions)(App);
AppRegistry.registerComponent('MyApp', () => App);

Resources