# Sinch Client The *SINClient* is the Sinch SDK entry point. it's used to configure the user's and device's capabilities, as well as providing access to feature classes such as the *SINCallClient*, and *SINAudioController*. ## Creating the *SINClient* Set up the client and its delegate (*SINClientDelegate*, see [Reference](https://sinch.github.io/docs/voice/voice-ios-cloud/reference/html/protocols/sinclientdelegate.html) documentation). ```objectivec #import // Instantiate a Sinch client NSError *error; id sinchClient = [Sinch clientWithApplicationKey:@"" environmentHost:@"ocra.api.sinch.com" userId:@"" error:&error]; ``` - The *Application Key* is obtained from the [Sinch Developer Dashboard - Apps](https://dashboard.sinch.com/voice/apps). - The *User ID* should uniquely identify the user on the particular device. - (The term *Ocra* in the hostname `ocra.api.sinch.com` is just the name for the Sinch API that the SDK clients target) ## Specifying Capabilities The *SINClient* can be configured to enable specific functionality depending on your use case. To enable support for *push notifications*, use the method `-[SINClient enableManagedPushNotifications]`. Also see [Push Notifications](/docs/in-app-calling/ios/push-notifications-callkit) for additional steps that are required to fully implement support for push notifications. ```objectivec [sinchClient enableManagedPushNotifications]; ``` ## Starting the *SINClient* Before starting the client, assign a *SINClientDelegate*. it's required to implement `-[SINClientDelegate requiresRegistrationCredentials:]` to [Authorize the Client](/docs/in-app-calling/ios/sinch-client#authorizing-the-client). ```objectivec // Assign as SINClientDelegate sinchClient.delegate = ... ; // Start the Sinch Client [sinchClient start]; ``` If the application is meant to only make outbound calls but not receive incoming calls, the client will be ready to make calls after the delegate has received the callback `clientDidStart:`. If the application is meant to receive incoming calls while not running in foreground, [Push Notifications](/docs/in-app-calling/ios/push-notifications-callkit) are required. ### Authorizing the Client When the *SINClient* is started with a given *User ID* it's required to provide a registration token to register as towards the *Sinch backend*. To authorize a client, implement `-[SINClientDelegate requiresRegistrationCredentials:]` and provide a token (a [JSON Web Token](https://jwt.io/)) that's cryptographically signed with the *Application Secret*. How to form and sign this token is described in detail in [Creating a Registration Token](/docs/in-app-calling/ios/auth). The sample applications included in the Sinch SDK includes a class `SINJWT` that describes how to create the *JWT* and sign it with the *Application Secret*. Also see [https://github.com/sinch/sinch-rtc-api-auth-examples](https://github.com/sinch/sinch-rtc-api-auth-examples) for examples in other programming languages. ```objectivec - (void) client:(id)client requiresRegistrationCredentials:(id)registrationCallback { NSString *jwt = [SINJWT jwtForUserRegistrationWithApplicationKey:@"" applicationSecret:@"" userId:client.userId]; [registrationCallback registerWithJWT:jwt]; } ``` When deploying your application to production, don't embed the *Application Secret* in the application. The example above is only meant to show how to provide a signed JWT to the `SINClient`. ### Life cycle Management of a *SINClient*-instance We recommend that you initiate the `SINClient`, start it, but not terminate it, during the lifetime of the running application. That also implies that the *SINClient*-instance should be *retained* by the application code. It's best to keep the client instance alive and started unless there are reasons specific to your application. It shouldn't be necessary to dispose of the client instance if memory warnings are received from iOS, because once the client is started it doesn't use much memory in comparison to view layers, view controllers etc. For the same reasons, if support for push notifications is enabled, the preferred method of temporarily stopping incoming calls is to [Unregister a Push Device Token](/docs/in-app-calling/ios/push-notifications-callkit). The `SINClient` can of course be completely stopped and also disposed. To do so, call `-[SINClient terminateGracefully]` before the application code releases its last reference to the client object. Example of how to completely dispose the `SINClient`: ```objectivec [sinchClient terminateGracefully]; sinchClient = nil; ```