Coder Social home page Coder Social logo

Apple watch support about qrcode HOT 9 OPEN

aschuch avatar aschuch commented on September 28, 2024 2
Apple watch support

from qrcode.

Comments (9)

antonioreyna avatar antonioreyna commented on September 28, 2024

I would like to add it to watch too.

from qrcode.

aschuch avatar aschuch commented on September 28, 2024

Should be possible, I'll try to add that alongside swift 2.3 and 3.0 support in the near future.

from qrcode.

diolce avatar diolce commented on September 28, 2024

he only way to show the clock qr is sending them from iPhone to watch

from qrcode.

antonioreyna avatar antonioreyna commented on September 28, 2024

i send a rendered png of the QR from my iphone app to the watch in a current project.

from qrcode.

diolce avatar diolce commented on September 28, 2024

I'm trying to do with WatchConnectivity but I find the error

Domain Error Code = 7014 = WCErrorDomain "Could not be delivered Payload." UserInfo = {NSLocalizedDescription = Payload Could not be delivered.}

This is the side of the watch
session.sendMessage ([ "reference" self.qr_data], replyHandler: {(response) -> Void in    if let imageQR = response [ "imageQR"] he? NSData, let boardingPass = UIImage (data: imageQR as Data) {       self.imagenPass = boardingPass       DispatchQueue.main.async (execute: {() -> Void in       self.showBoardingPass ()        })      }}, ErrorHandler: {(error) -> Void in               print (error)    })

 On the side of the phone (AppDelegate.swift)
func session (_ session: WCSession, didReceiveMessage message: [String: Any], replyHandler: @escaping ([String: Any]) -> void) {         if let reference = message [ "reference"] he? String, let boardingPass = QRCode (reference) {             replyHandler ([ "imageQR" boardingPass.PNGData as AnyObject])         }     }

I am with watchOS3 and iOS10 in previous versions these methods functioned. I don´t know if be a problem of simulator. Any help would be greatly appreciated.
A greeting.

from qrcode.

antonioreyna avatar antonioreyna commented on September 28, 2024

i send the QR like this:

func createImageForWatch(_ qr_string: String) {

        if WCSession.isSupported() {
            WCSession.default().delegate = self
            WCSession.default().activate()
        } else {
            return
        }

        if var qrCodeObject = QRCode(qr_string) {
            qrCodeObject.size = CGSize(width: 135, height: 135)
            qrCodeObject.color = CIColor(color: UIColor.black)
            qrCodeObject.backgroundColor = CIColor(color: UIColor.white)

            let qrImg = qrCodeObject.image!
            let data = UIImageJPEGRepresentation(qrImg!, 1.0)

            let userInfo: [String: Any] = [
                "QR" : data!
            ]
            WCSession.default().transferUserInfo([
                "MyData" : userInfo
                ])
        }
    }

from qrcode.

antonioreyna avatar antonioreyna commented on September 28, 2024

@diolce i think the problem could be that, now you need to have all the delegate methods in the session delegate.

in my case in the viewController that creates the image i have this as that is my delegate.

//MARK: WatchConnectivity Session Delegate
    func session(_ session: WCSession, activationDidCompleteWith activationState: WCSessionActivationState, error: Error?) {
        print("activationDidCompleteWith")
    }

    func sessionDidBecomeInactive(_ session: WCSession) {
        print("sessionDidBecomeInactive")
    }

    func sessionDidDeactivate(_ session: WCSession) {
        print("sessionDidDeactivate")
    }

from qrcode.

BassApps avatar BassApps commented on September 28, 2024

Hey @antonioreyna
can you tell me why it is 135 instead of 136? Apple Watch 38 size is 272, not 270 so I'd like to know why it's better to use the 135 value.

Thanks

from qrcode.

antonioreyna avatar antonioreyna commented on September 28, 2024

hello, in my case i added it a table row and i wanted some padding so i used that size 😃

from qrcode.

Related Issues (20)

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.