App lifecycle events

Please confirm whether installed and updated callbacks are working.

smartapp-sdk-nodejs/smart-app.js at 37fdf3bfdffae7c9da54be2955c5c30c2588f72b · SmartThingsCommunity/smartapp-sdk-nodejs · GitHub

I don’t believe they are called. I can only get the uninstalled callback to work.

To reproduce, add the following lines at this SmartApp example:
api-app-subscription-example-js/server.js at 89433bbb8e27dabb0c944a5342b48d884f6f0e11 · SmartThingsCommunity/api-app-subscription-example-js · GitHub

.installed(() => console.log('INSTALLED'))
.updated(() => console.log('UPDATED'))
1 Like

Those lifecycles belong to the traditional SmartApp and they are executed when the user clicks on “install” or “done” after selecting a value for the required SmartApp settings.

Can you share what do you need from those lifecycles?

Based on this sample, the events are handled by the SmartApp thanks to this line:

And, configuring the “Target URL” property of the API Access app at the Developer Workspace.

1 Like

Well, I expected install/updated to be called upon update and install as the names suggest, since the documentation does not mention that these callbacks are reserved for the traditional SmartApps.

Whether an installedApp is new or updated can be determined manually. Too bad the SDK does not provide this functionality.

By “updates” in this case, do you mean in case the user changes something on the OAuth page? For example, in case they give permissions to new devices.
If not, which kind of updates in the installedApp do you need to identify?

Yes, this is one obvious case.

Device selection change could be handled in the oAuth callback, but this logic really belongs to the SmartApp definition, rather than the server that hosts the SmartApp.

When it comes to app life-cycle callbacks, the difference between API_ONLY and WEBHOOK_SMART_APP is not documented, neither in the SDK or the API, so this behaviour is counter intuitive. However, this is not a road block, since there’s a reasonable workaround.