Can someone please tell me how I can interact with the smartthings api from an iOS application?

I have an iOS application that functions as a dashboard control panel. I began working on this a few years ago just casually, and I am almost done. I know that im not a professional developer and I do not claim to be, and im likely going to seem super naive to anyone who has a clue about this stuff. but why in the WORLD do you have an api that supposedly allows us to be able to interact with devices a user has already added to your application, and then make it so IMPOSSIBLY DIFFICULT to authenticate to be able to do so? for starters, I cannot figure out how to create a button, in an iOS app, (so, written in swift and using Xcode), which a user of my app can tap and be taken to smarttthings to sign in, and then be shown a simple list of their devices, allow them to choose the ones they want to use on my app, and then be brought back to the app. iOS uses custom url schemes, which are not https. but smartthings REQUIRES that the callback uri is https. which means I have to write an ENTIRE SERVER to act as a middleman to facilitate communications between smartthigns and my app, and smartthings is just one of the platforms im trying to interact with! why is it so difficult?! there has to be something stupid that im missing, please, if someone can help me avoid rippping all of my hair out I just need to be able to subscribe to and control devices on an app. it seems like such a simple idea. if someone can point me to the proper way of doing this, I will send you a thank you card or something.

Hi, @delray2
Yes, HTTPS is required, if this is a personal project you can use ngrok to create a tunnel that helps you out.

The subscriptions are the events sent from SmartThings to your server, so, it must be a secure endpoint. In the case of commands, you can authenticate the request using your Personal Access Token instead.

1 Like

I wrote it in glitch. But, now when i tap on my button it makes me login everytime. So what information do i need to pass from the glitch server to my custom url scheme, that will allow my app access to, or the abillity to create, refresh tokens? Using the smartapp sdk, it doesnt seem like my server is ever actually exposed to it, as the token is aquired via “smartapp.handleoauthcallback”

Im making the program for multiple users in my home, and as such have a need to allow them to sign into their personal accounts. Asking them each to create PATs will be too involved and will defeat my purpose.

I don’t know how’s your configuration in Glitch, but if you’re using the free version, remember it will stay in IDLE state every 5 minutes.

Have you checked this example? It uses an API_ACCESS app and creates subscriptions. It saves the SmartApp’s context locally to get the tokens and refresh them if necessary: