GithubHelp home page GithubHelp logo

SwiftUI integration about ios-sdk HOT 5 CLOSED

doorbell avatar doorbell commented on July 26, 2024
SwiftUI integration

from ios-sdk.

Comments (5)

manavo avatar manavo commented on July 26, 2024

Hi @thomasmo3!

I'd need to look into that, not 100% sure what that would look like. But I'm guessing something along these lines would help get it to work!

https://www.captechconsulting.com/blogs/combining-swiftui-with-viewcontrollers

Thanks,
Phil

from ios-sdk.

tomsun3 avatar tomsun3 commented on July 26, 2024

Hi @manavo,

thanks for your quick response!
That should work, but I think there might be a better way to add it into a SwiftUI view directly. Currently, I'm also not sure how. Although, this would be great for other users as well to be added to the instructions of Doorbell integration for iOS, I think.

all the best,
Thomas

from ios-sdk.

manavo avatar manavo commented on July 26, 2024

Hi @thomasmo3,

I've just been doing some tests for this, and this seems to work for SwiftUI:

// In your View, define a button or something to trigger the feedback dialog
Button(action: feedback) {
    Label("Feedback", systemImage: "plus")
}

// In the same struct, create a function that can be called to initialize Doorbell
private func feedback() {
    var currentKeyWindow: UIWindow? {
      UIApplication.shared.connectedScenes
        .filter { $0.activationState == .foregroundActive }
        .map { $0 as? UIWindowScene }
        .compactMap { $0 }
        .first?.windows
        .filter { $0.isKeyWindow }
        .first
    }

    var rootViewController: UIViewController? {
      currentKeyWindow?.rootViewController
    }

    
    let appId = "ID-HERE"
    let appKey = "KEY-HERE"

    let feedback = Doorbell.init(apiKey: appKey, appId: appId)

    feedback!.showFeedbackDialog(in: rootViewController, completion: { (error, cancelled) -> Void in
        if (error?.localizedDescription != nil) {
            print(error!.localizedDescription);
        }
    })
}

Would something like this work for you?

Thanks,
Phil

from ios-sdk.

tomsun3 avatar tomsun3 commented on July 26, 2024

Thank you, @manavo !

Works pretty well. This sould be added to the documents for your users.
I decided to create my custom UI now and directly use your library to send the feedback.
Your provided feedback dialog does not look really beautiful IMHO, maybe this might need some improvement :) (Also, I'm not creating an issue for that now...

All the best and read you soon,
Thanks, also for our email communication,
Thomas

from ios-sdk.

manavo avatar manavo commented on July 26, 2024

Great to hear that it works at least, it's a good starting point! Thanks for confirming @thomasmo3!

I'll add this to the docs for now since it gets it working. And yes I do agree that it wouldn't really win any design awards, but I'll see what I can do about that too :)

Thanks,
Phil

from ios-sdk.

Related Issues (12)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.