realm

Realm SyncUser.authenticate failed with Google's clientID and Facebook

守給你的承諾、 提交于 2019-12-10 11:13:42
问题 I'm using Google for authenticating, like following: let credential = Credential.google(token: "<SOME-HASH-HERE>.apps.googleusercontent.com") SyncUser.authenticate(with: credential, server: serverURL, timeout: 60) { [weak self] user, error in guard nil == error else { print("error while authenticating: \(error!)") return } … } It gives an error 400. After some debugging I found more info about the problem, but still not sure what is wrong with that. So response looks like this: { "invalid

How to set default realm path to App Groups directory

拈花ヽ惹草 提交于 2019-12-10 10:44:42
问题 I am trying to set the default Realm path to App Groups directory. let directory: NSURL = NSFileManager.defaultManager().containerURLForSecurityApplicationGroupIdentifier("groups.prasanna.appName")! RLMRealm.setDefaultRealmPath(directory.absoluteString!) println(RLMRealm.defaultRealmPath()) The app crashes with the following error Terminating app due to uncaught exception 'RLMException', reason: 'open() failed: Operation not permitted' How do I fix this issue? 回答1: the default realm path you

How to encode Realm's List<> type

假如想象 提交于 2019-12-10 10:37:16
问题 I am trying to encode my Realm database to JSON. Everything is working except the List<> encoding. So my question is, how would you encode List<> ? Because the List doesn't conform to Encodable neighter Decodable protocol. Right now I am doing this: @objcMembers class User: Object, Codable{ dynamic var name: String = "" let dogs = List<Dog>() private enum UserCodingKeys: String, CodingKey { case name case dogs } convenience init(name: String) { self.init() self.name = name } func encode(to

How to write to a Realm object server on Ubuntu

爱⌒轻易说出口 提交于 2019-12-10 10:24:58
问题 I have worked through the Realm mobile platform tutorial (link). You create a Swift task app. I was able to get the app and server working correctly on my local mac. I was able to add tasks to the tableview. I then created an Ubuntu 16.04 droplet on DigitalOcean. I managed to get the server running and am able to view the Realm dashboard. The problem is that when I run the app with the new server ip address (the ubuntu instance), I see the 'Add task' pop up but no tasks get added to the

Sharing Realm instance between React Native and Android

落爺英雄遲暮 提交于 2019-12-10 10:22:00
问题 I'm working on a React Native project that uses Realm for React Native. It works without problems but now, I am faced with a problem of writing Android Service that would use the same Realm instance. Is it possible and how would I do that? 回答1: I think you can communicate from Java to React Native through Native Modules and do your Realm-related code in Javascript as you normally would. Otherwise, Realm for Android's multi-process support for non-encrypted Realms will arrive in Realm-Java 2.0

Why does Realm suggest that List<T> properties be declared using “let”?

馋奶兔 提交于 2019-12-10 09:37:49
问题 Realm's documentation on to-many relationships declares its List<Dog> property using let : class Person: Object { // ... other property declarations let dogs = List<Dog>() } Why is this List<T> property declared using let when other Realm property types are declared using dynamic var ? 回答1: List<T> properties should be declared using let as Realm is unable to intercept assignment to these properties. Assigning to List<T> properties won't result in your changes being persisted to the Realm

Replace Realm file while app is running

痞子三分冷 提交于 2019-12-10 04:37:08
问题 To implement the backup / restore feature, I am deleting the existing Realm database file and replacing it with the new database file with the same name. However, with the app still running it does not see the contents of the new database file. If I quit and relaunch the app, it does see the contents of the new database file. Is there any way to make the app see the new contents without having to relaunch it? 回答1: Much like deleting a Realm file from disk, it's only safe to replace a Realm

Can I use RestKit and Realm.io?

心已入冬 提交于 2019-12-10 03:34:35
问题 I want to use RestKit, but I already use Realm.io instead of CoreData. Is it possible to use RestKit on top of Realm.io? 回答1: Sure you can. Once you get the object back from RestKit: // GET a single Article from /articles/1234.json and map it into an object // JSON looks like {"article": {"title": "My Article", "author": "Blake", "body": "Very cool!!"}} RKObjectMapping *mapping = [RKObjectMapping mappingForClass:[Article class]]; [mapping addAttributeMappingsFromArray:@[@"title", @"author", @

Realm access from incorrect thread Android

夙愿已清 提交于 2019-12-10 03:32:18
问题 I am dealing with this issue on Android : Realm access from incorrect thread. Realm objects can only be accessed on the thread they where created. I want to use Realm in my RemoteViewsFactory with public class RemoteViewsX implements RemoteViewsFactory { public RemoteViews getViewAt(int paramInt) { if (this.results != null && this.results.size() != 0 && this.results.get(paramInt) != null) { //FAILED HERE } } ... This call failed! Why ? I fetch my data like this in my class: public void

Return unique/distinct values with Realm query

牧云@^-^@ 提交于 2019-12-10 03:04:02
问题 I have a Message/RLMObject model that has a NSString *jabberID property/row and I want to retrieve every unique value inside that row. In other word, I want to retrieve non-repeated jabberID values from my Message model. Can anyone help out figuring this? The way I use to do with coredata was using returnsDistinctResults setting on the NSFetchRequest . 回答1: Functional programming approach since Swift has it, and Realm lazy loads; Not as easy/available a solution in Objective-C but for Swift