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

Setting PERSISTENCE = YES #444

Closed
sjhennion opened this issue Apr 4, 2018 · 1 comment
Closed

Setting PERSISTENCE = YES #444

sjhennion opened this issue Apr 4, 2018 · 1 comment

Comments

@sjhennion
Copy link

I'm not sure if this is an issue, or if I'm misunderstanding something. When I create a session, as the MQTTSession header suggests, I immediately set the persistence flag to true with an MQTTCoreDataPersistence object. However, since there's no initializer for the MQTTCoreDataPersistence type that takes a persistence value, by the time createPersistentStoreCoordinator: is called, persistence is still set to the default of NO, so the persistent store isn't created with my YES (true).

What this means for me is that if I start my app either with airplane mode on, or disabling it soon after launch, attempt to publish some data, and then kill the app before ever restoring the connection, the data is not available and attempting to publish on the next instance. However, I tried setting the default value for persistence to yes rather than no, and everything worked as expected.

For what it's worth, here's my session initialization:

    func prepManager(userName: String, password: String, deviceId: String) {
        guard let _session = MQTTSession() else {
            print("Error getting MQTT sesh")
            return
        }
    
        let persistence = MQTTCoreDataPersistence()
        persistence.persistent = true
        _session.persistence = persistence

        /* Other session settings */

        self.session = _session
    }
jcavar added a commit that referenced this issue Apr 24, 2018
[FIX] Setting PERSISTENCE = YES #444
@jcavar
Copy link
Contributor

jcavar commented Apr 25, 2018

Thanks for reporting!

There is now 0.14.0 release, please try it out.

@jcavar jcavar closed this as completed Apr 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants