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

Apple watch support #27

Open
mohanmoorthy opened this issue Jun 9, 2016 · 9 comments
Open

Apple watch support #27

mohanmoorthy opened this issue Jun 9, 2016 · 9 comments

Comments

@mohanmoorthy
Copy link

Is it possible to add extension for apple watch ?

@antonioreyna
Copy link

I would like to add it to watch too.

@aschuch
Copy link
Owner

aschuch commented Sep 6, 2016

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

@diolce
Copy link

diolce commented Oct 26, 2016

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

@antonioreyna
Copy link

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

@diolce
Copy link

diolce commented Oct 28, 2016

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.

@antonioreyna
Copy link

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
                ])
        }
    }

@antonioreyna
Copy link

@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")
    }

@BassApps
Copy link

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

@antonioreyna
Copy link

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

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

5 participants