Basic Setup
Before you can start communicating with Mitter using the SDK, it needs to be configured with your application ID and user auth token ID.
The best place to configure a global
Mitter
object is inside your AppDelegate.swift
file.Open up the
AppDelegate
file and declare an instance field for the Mitter
object, like this:var mitter: Mitter = Mitter(applicationId: "")
After you’ve done that, locate the function with
didFinishLaunchingWithOptions
signature and initialise your Mitter
object with your application and user details like this:mitter = Mitter(
applicationId: "MZzf4-na9nL-O98wq-M1HxS",
userAuthToken: "eyJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJtaXR0ZXItaW8iLCJ1c2VyVG9rZW5JZCI6IkhYbkZJSXIydUpQRHMzankiLCJ1c2VydG9rZW4iOiJhaHFtNTgzcjRwbzEwZmNqZTllaHE5dDV1NCIsImFwcGxpY2F0aW9uSWQiOiJNWnpmNC1uYTluTC1POTh3cS1NMUh4UyIsInVzZXJJZCI6ImNzckN5LVNKTDN1LThBS01ULVdxdjZ5In0.FTgn0GBgIQrA0NznQEUHyC7SN7rbN9O9cWlI5mejuDG466VSJHjwGWZF2DB3nsn8eoeCg5toIXXh5Sxz2MMU3w"
)
The user token is enough to help the SDK figure out the user ID. Therefore, you don’t need to explicitly add the user ID. You can get both these values from the mitter.io dashboard.
If you're using the Mitter.io docker container, then you need to override the default API endpoint in the SDK, as follows:
mitter = Mitter(
applicationId: "MZzf4-na9nL-O98wq-M1HxS",
userAuthToken: "eyJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJtaXR0ZXItaW8iLCJ1c2VyVG9rZW5JZCI6IkhYbkZJSXIydUpQRHMzankiLCJ1c2VydG9rZW4iOiJhaHFtNTgzcjRwbzEwZmNqZTllaHE5dDV1NCIsImFwcGxpY2F0aW9uSWQiOiJNWnpmNC1uYTluTC1POTh3cS1NMUh4UyIsInVzZXJJZCI6ImNzckN5LVNKTDN1LThBS01ULVdxdjZ5In0.FTgn0GBgIQrA0NznQEUHyC7SN7rbN9O9cWlI5mejuDG466VSJHjwGWZF2DB3nsn8eoeCg5toIXXh5Sxz2MMU3w",
mitterApiEndpoint: "http://localhost:11901"
)
Last modified 4yr ago