I'm implementing chat app and have to use transaction to synchronize messages of users. But, there are fatal error which terminates application abruptly. How can I deal with?
I searched many materials for this, but there was no solution. Github issue is related on this and I already wrote issue on this.
Future<void> sendMessage(String content,String receiver,String chatRoomID) async {
DocumentReference doc = Firestore.instance
.collection(firestoreMessageCollection)
.document(chatRoomID)
.collection(chatRoomID)
.document(DateTime.now().millisecondsSinceEpoch.toString());
await Firestore.instance.runTransaction((tx) async{
await tx.set(doc,{
firestoreChatFromField: sl.get<CurrentUser>().uid,
firestoreChatToField: receiver,
firestoreChatTimestampField: DateTime.now().millisecondsSinceEpoch.toString(),
firestoreChatContentField: content
});
});
}
I expected right result which transaction does normally, but below error is occurred and application was terminated.
E/AndroidRuntime( 1719): Caused by: java.lang.IllegalArgumentException: Provided document reference is from a different Firestore instance.
Even if I'm using same firestore instance, it is occurred continuously. Are there anyone who solved this horrible problem?
It was related on the firestore setting. When you initialize firestore settings, jus use Firestore.instance. If you use other instance, it occurs my error
I was also getting the same issue. It was fixed when I updated document reference code. Can you try changing document reference
from:
DocumentReference doc = Firestore.instance
.collection(firestoreMessageCollection)
.document(chatRoomID)
.collection(chatRoomID)
.document(DateTime.now().millisecondsSinceEpoch.toString());
to:
DocumentReference doc = Firestore.instance.document('$firestoreMessageCollection/$chatRoomID/$chatRoomID/${DateTime.now().millisecondsSinceEpoch.toString()}');
I also updated dependencies versions. In my case these are:
firebase_core: ^0.4.0+6
firebase_auth: 0.11.1+7
cloud_firestore: 0.12.5+2
firebase_storage: ^3.0.2
firebase_messaging: ^5.0.4
firebase_crashlytics: ^0.0.4+8
Related
I'm currently experiencing this issue https://github.com/rnmapbox/maps/issues/2514
wherein inside my code mapbox component, if compassViewPosition is added, it terminates the app without even throwing an error. anyone else encountered something related to this (read, passed through or dreamt about); feel free to comment out. Happy to get enlightened here.
import React from 'react';
import MapboxGL from '#rnmapbox/maps';
class BugReportExample extends React.Component {
render() {
return (
<MapboxGL.MapView
compassViewPosition={3} // adding this line terminates the app (not tested in android yet, and no error from try catch)
/>
);
}
}
I'm in "react-native": "~0.66.5" and I'm using "#rnmapbox/maps": "rnmapbox/maps#main",
Previous package I'm using was "#react-native-mapbox-gl/maps": "^8.5.0" and it works fine here. I'm trying to upgrade to the newer package (I know it's not on stable release yet but wanna know if I'm the only one experiencing this).
I got a run time error during a debug run of my Xcode project for iOS. The project was running on an iPhone 8 device running iOS 15.5. I am using Xcode version 13.4.1 on a Mac Pro running macOS Monterey version 12.5.
The error message occurred at a line of code where I initialize a custom struct.
Thread 3: EXC_BAD_ACCESS (code=2, address=0x16dbc7ff0)
Here is my relevant code. The error message shows in red where GroupLocalCache is being initialized.
import Foundation
import CloudKit
// Wrap a CKRecordZone and its caches (each record type should have its records saved in the caches.
//
final class Zone {
let cloudKitZone: CKRecordZone
let caches = [BaseLocalCache]()
private var groupCache: GroupLocalCache
init(cloudKitZone: CKRecordZone, container: CKContainer, cloudKitDB: CKDatabase) {
self.cloudKitZone = cloudKitZone
self.groupCache = GroupLocalCache(container: container, cloudKitDB: cloudKitDB, cloudKitZone: cloudKitZone)
}
}
Here is the code for GroupLocalCache:
final class GroupLocalCache: BaseLocalCache {
let container: CKContainer
let cloudKitDB: CKDatabase
let zone: Zone
private var serverChangeToken: CKServerChangeToken?
private var groups = [Group]()
init(container: CKContainer, cloudKitDB: CKDatabase, cloudKitZone: CKRecordZone) {
self.container = container
self.cloudKitDB = cloudKitDB
self.zone = Zone(cloudKitZone: cloudKitZone, container: container, cloudKitDB: cloudKitDB)
super.init()
fetchChanges() // Fetching changes with a nil token to build up the cache.
}
}
BaseLocalCache is a modified version of the BaseLocalCache class that comes with CloudKitShare Xcode project from this Apple webpage: Sharing CloudKit Data with Other iCloud Users.
I want to look up what that "2" represents in the message where it says "code=2".
Other posts on stackoverflow* and Apple's Developer Forums for this same error address specific situations different than the error in my code.
I would like to know what the low level cause of the error is, so I need to know what those codes are that show up in exception error messages, since they tell what the real cause of exception error are in a lower level than answers to posts about exception errors commonly found.
I think I found documentation at one time for those codes at another source outside of Apple. It seems there are codes that are used by hardware manufacturers for "architectures" such as "arm64" and "armv7". I see those in Xcode project build settings.
Do I really need to know what each code as given in the error message represent?
I found this article at Apple's Developer Documentation:
Understanding the Exception Types in a Crash Report
I found this documentation on Apple's Exception Handling Framework in a search with Google: Exception Handling. I don't see what I need. This framework seems to be more than I need at this time.
You currently have an infinite loop of object creations. That's why you get a crash.
When crashing, do not hesitate to see the callstack, you should see it clearly.
The Zone initialization, calls a GroupLocalCache initialization, which calls a Zone initialization, which will call a GroupLocalCache initialization, etc.
So you need to change the logic on your objects.
So, I wanted to include firebase into my Flutter App, it works fine for android but when I start it on my ios emulator it will always give me this error
[VERBOSE-2:ui_dart_state.cc(209)] Unhandled Exception: [core/not-initialized] Firebase has not been correctly initialized.
Usually this means you've attempted to use a Firebase service before calling Firebase.initializeApp.
View the documentation for more information: https://firebase.flutter.dev/docs/overview#initialization
I have the google-service file in the right directory and I followed the tutorial and edited my main() to:
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
runApp(const MyApp());
}
Has anybody the same problem with IOS or did I do anything wrong?
So for everybody else getting this error I figured it out myself, for IOS, the line
Firebase.initializeApp()
it needs an option:
Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform)
for that follow the instructions on this link:
https://firebase.flutter.dev/docs/cli
hope that helps anyone
Install Firebase CLI if it is not installed in your system.
Next, install the FlutterFire CLI or by running the following command:dart pub global activate flutterfire_cli. Once installed, the flutterfire command will be globally available.
Run flutterfire configure in your flutter project folder in terminal,
Select a Firebase project to configure your Flutter application with,
Select/Insert android app id and bundle id you want to use as and when it asks you.
and get firebase_options.dart.
In main.dart file import firebase_options.dart.
In void main() use following code.
WidgetsFlutterBinding.ensureInitialized();
if (Platform.isIOS) {
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
} else {
await Firebase.initializeApp();
}
runApp(
const MaterialApp(
home: MyApp(),
),
);
I got same problem. My Android application is working fine but when using IOS application it's throw this type of exception. you can use #Viki's answer and if its not working for you make sure you have added GoogleServices-info.plist file in your ios project.
If it's not solve your issue then use this code
if (Platform.isIOS) {
await Firebase.initializeApp(
options: FirebaseOptions(
apiKey: "your api key Found in GoogleService-info.plist",
appId: "Your app id found in Firebase",
messagingSenderId: "Your Sender id found in Firebase",
projectId: "Your Project id found in Firebase"));
} else {
await Firebase.initializeApp();
}
I have faced the same issue in my flutter application when run on xcode/ ios.
Here is how I solved.
Download GoogleService-Info.plist from firebase account
Add Files to Runner like below and choose GoogleService-Info.plist from download folder
Re-Run the project, It will work
In my case, I haven't added the code lines according to the instructions from firebase. The simple fix is to follow the instructions from the firebase doc from start to finish.
In my case, I forgot to add await because it returns Future.
Previously:
Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
Then
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
Here is the full function to copy paste.
Convert the main function to:
Future main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
runApp(const MyApp());
}
I created a new xCode project (swiftUI) and I followed the guide to install the Indy iOS SDK.
Link: https://github.com/hyperledger/indy-sdk/blob/master/wrappers/ios/README.md
The pod has been installed correctly and I can call the various functions offered by the SDK.
I would like to perform the following operations in sequence:
Create a wallet
Open the wallet
I tried to nest the two operations:
let error = indy_create_wallet(0, walletConfig, credentials, {(commandHandle, err) in
print("Create wallet error: ", err)
let error = indy_open_wallet(1, self.walletConfig, self.credentials, {(commandHandle2, err2, handle) in
print("Open wallet error: ", err2)
})
})
But, in this case I get the error: A C function pointer cannot be formed from a closure that captures context
I tried to use the DispatchGroup but again I get the same error as I have to call the leave() method on the object inside the callback.
Unfortunately I cannot use the "libindy-objc" wrapper because it is not compatible with the version of swift I am using.
Does anyone have any ideas on how I can manage these callbacks to sequentially execute the wallet creation and opening operation? Thanks!
To solve the problem I imported (inside a new group) the wrapper source files.
Why not to use already prepared wrappers on github?
https://github.com/hyperledger/indy-sdk/tree/master/wrappers/ios/libindy-pod/Indy/Wrapper
This is written in ObjC but using Swift it can generate a mapping interface, then you can sequence operations using DispatchSemaphore with .signal and .wait
I am currently using the latest version of Parse 1.14.2 and Bolts 1.8.4.Parse is implemented correctly and I have been using it for a long time now. The problem I'm facing now is when I try to use Parse's local datastore. I have the following code in my AppDelegate.swift:
Parse.enableLocalDatastore()
Parse.setApplicationId("ID",
clientKey: "Client_Key")
I have the following code to create and save a string named firstName in a class named contact:
let contact = PFObject(className: "contact")
contact["firstName"] = "Jack"
contact.pinInBackground()
Here is the code to retrieve objects from the created class:
let query = PFQuery(className: "contact")
query.fromLocalDatastore()
query.getFirstObjectInBackgroundWithBlock({ (object, error) -> Void in
if error == nil {
if let contact = object {
print(contact.objectForKey("firstName"))
}
}
})
I have added libsqlite3.dylib to my project. My app doesn't crash when I run this code but it simply gives me the following message when I try to retrieve objects:
2016-08-29 11:31:38.049 App_Demo[14436:3504319] [Bolts] Warning: `BFTask` caught an exception in the continuation block.
This behavior is discouraged and will be removed in a future release.
Caught Exception: Method requires Pinning enabled.
Can anyone help me to work around this issue? I am guessing the issue is that this version of Bolts cannot pin Parse objects in the background and I need to work my way around this bug. Any help would be appreciated as I have been stuck at this for a while and can't find too much info online.
Edited: I have tried downgrading Bolts, but then Parse downgrades with it in Cocoapod and it causes errors in Xcode.
it's not objectforkey.
You need to call object["UsedName"] "UsedName" being the key. Hope that helps.