Create a Function Instance

Catalyst functions enable you to build custom functionalities in your application, automate tasks, or integrate with third-party services. You can develop functions for your iOS app from the Catalyst console or the CLI.

Create a Function Instance

You can create an instance of a Catalyst function using the getFunctionInstance() method, and enable the methods defined in this class to access the instance object. This will prevent unnecessary server calls.

You can create a function instance in any of the following ways:

i. By passing the Function ID

You can pass the function’s unique Function ID as an argument to the getFunctionInstance() method and create an instance for it:

    
copy
ZCatalystApp.shared.getFunctionInstance( id : Int64 ) -> ZCatalystFunction

Parameters:

A sample code snippet is shown below:

    
copy
let function_instance = ZCatalystApp.shared.getFunctionInstance ( id : 1096000000002053 ) //Replace this with your Function ID

ii. By passing the name of the function

You can pass the function’s API name as an argument to the getFunctionInstance() method and create an instance for it:

    
copy
ZCatalystApp.shared.getFunctionInstance( name : String ) -> ZCatalystFunction

Parameters:

  • name: The name of the function configured in Catalyst

A sample code snippet is shown below:

    
copy
let function_instance = ZCatalystApp.shared.getFunctionInstance ( name : "LocalBackup") //Replace this with you function name

Last Updated 2023-09-03 01:06:41 +0530 +0530