# Cannot find type 'SessionHandler' in scope

**URL:** <https://forum.social.plus/t/cannot-find-type-sessionhandler-in-scope/1172>\
**Category:** iOS\
**Created:** [March 5, 2024, 11:59am UTC](https://forum.social.plus/t/cannot-find-type-sessionhandler-in-scope/1172 "2024-03-05T11:59:12Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Raj](https://avatars.discourse-cdn.com/v4/letter/r/c0e974/32.png) [@Raj](https://forum.social.plus/u/Raj)\
**Post date:** [March 5, 2024, 11:59am UTC](https://forum.social.plus/t/cannot-find-type-sessionhandler-in-scope/1172/1 "2024-03-05T11:59:12Z")

</div>

we have integrated Amity swift uikit , we tried to manage session but finding issue  
and already import AmitySDK, import AmityUIKit, i tried your sample app in which it is working , and SessionHandler finds in AmitySDK, in our app AmitySDK , we don’t find it.

Cannot find type ‘SessionHandler’ in scope

---

<div class="post-metadata">

**Author:** ![SocialPlus\_Support](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.social.plus/socialplus_support/32/798_2.png) [@SocialPlus\_Support](https://forum.social.plus/u/SocialPlus_Support)\
**Post date:** [March 6, 2024, 5:22am UTC](https://forum.social.plus/t/cannot-find-type-sessionhandler-in-scope/1172/2 "2024-03-06T05:22:56Z")

</div>

Hello @Raj, please try replacing the below code and let us know if you still facing the issue.

```auto
import AmitySDK
import UIKit
import UserNotifications
class ViewController: UIViewController {
    let client = try! AmityClient(apiKey: "Put your apikey here", region: .EU)
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        // Create a button for setup
        let setupButton = UIButton(frame: CGRect(x: 100, y: 100, width: 200, height: 50))
        setupButton.backgroundColor = .blue
        setupButton.setTitle("Setup", for: .normal)
        setupButton.addTarget(self, action: #selector(setupAction), for: .touchUpInside)
        self.view.addSubview(setupButton)
        
        // Create a button for login
        let loginButton = UIButton(frame: CGRect(x: 100, y: 200, width: 200, height: 50))
        loginButton.backgroundColor = .green
        loginButton.setTitle("Login", for: .normal)
        loginButton.addTarget(self, action: #selector(loginAction), for: .touchUpInside)
        self.view.addSubview(loginButton)
        
        // Create a button for registering push notification
        let registerPushNotificationButton = UIButton(frame: CGRect(x: 100, y: 300, width: 200, height: 50))
        registerPushNotificationButton.backgroundColor = .red
        registerPushNotificationButton.setTitle("Register Push", for: .normal)
        registerPushNotificationButton.addTarget(self, action: #selector(registerPushNotificationAction), for: .touchUpInside)
        self.view.addSubview(registerPushNotificationButton)
    }

    @objc func setupAction() {
      
    }

    @objc func loginAction() {
        login()
    }

    @objc func registerPushNotificationAction() async {
        await registerPushNotification()
    }

    func login() {
        Task {
            do {
                try await client.login(
                    userId: "silverhand",
                    displayName: "silverhand",
                    authToken: nil,
                    sessionHandler: MySessionHandler()
                )
                await showAlert(title: "Success", message: "Login successful")
            } catch {
                await showAlert(title: "Error", message: "Login failed: \(error)")
            }
        }
    }

    func registerPushNotification() async {
        do {
            let token = deviceTokenString
            print(token)
            let result = try await client.registerPushNotification(withDeviceToken: "")
            await showAlert(title: "Success", message: "Push notification registration successful")
        } catch {
            await showAlert(title: "Error", message: "Error registering push notification: \(error)")
        }
    }

    @MainActor
    func showAlert(title: String, message: String) async {
        let alert = UIAlertController(title: title, message: message, preferredStyle: .alert)
        alert.addAction(UIAlertAction(title: "OK", style: .default))
        
        if let topController = UIApplication.shared.keyWindow?.rootViewController {
            topController.present(alert, animated: true, completion: nil)
        }
    }

}
class MySessionHandler: SessionHandler {
    func sessionWillRenewAccessToken(renewal: AccessTokenRenewal) {
        renewal.renew()
    }
}

```

---

<div class="post-metadata">

**Author:** ![Raj](https://avatars.discourse-cdn.com/v4/letter/r/c0e974/32.png) [@Raj](https://forum.social.plus/u/Raj)\
**Post date:** [March 6, 2024, 9:43am UTC](https://forum.social.plus/t/cannot-find-type-sessionhandler-in-scope/1172/3 "2024-03-06T09:43:29Z")

</div>

> [@SocialPlus\_Support](#):
>
> ```auto
> import AmitySDK
> import UIKit
> import UserNotifications
> 
> ```

@SocialPlus_Support We have tried this code but We could not find class SessionHandler class in AmitySDK and showing error “Cannot find type ‘SessionHandler’ in scope” , while your sample app Amity SDK has this class.

 ![Screenshot 2024-03-06 at 3.14.48 PM](https://europe1.discourse-cdn.com/flex013/uploads/amity/original/1X/23dc35d9f9070a74ef46ac355aa0bacbb6d04f11.png)

---

<div class="post-metadata">

**Author:** ![SocialPlus\_Support](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.social.plus/socialplus_support/32/798_2.png) [@SocialPlus\_Support](https://forum.social.plus/u/SocialPlus_Support)\
**Post date:** [March 6, 2024, 11:08am UTC](https://forum.social.plus/t/cannot-find-type-sessionhandler-in-scope/1172/4 "2024-03-06T11:08:26Z")

</div>

Hello @Raj , After reviewing with our team, we advise you that SwiftUI has been deprecated. Therefore, we recommend using our UIKit as an alternative. Please check the documentation at this link: [Amity UIKit iOS Installation Guide](https://docs.amity.co/amity-uikit/ios/ios-uikit-installation-guide).

---

<div class="post-metadata">

**Author:** ![Raj](https://avatars.discourse-cdn.com/v4/letter/r/c0e974/32.png) [@Raj](https://forum.social.plus/u/Raj)\
**Post date:** [March 7, 2024, 6:30am UTC](https://forum.social.plus/t/cannot-find-type-sessionhandler-in-scope/1172/5 "2024-03-07T06:30:27Z")

</div>

@SocialPlus_Support thanks, installation is done as you suggested , we have created channels (public community), channels joining is working, but UIKit is not showing channels list, we use this code

let chatHomePageVC = AmityChatHomePageViewController.make()  
self.navigationController?.pushViewController(chatHomePageVC, animated: true)  
(upload://aQvdZ0eo8ofOTXvbWReankiHXvy.png)

---

<div class="post-metadata">

**Author:** ![SocialPlus\_Support](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.social.plus/socialplus_support/32/798_2.png) [@SocialPlus\_Support](https://forum.social.plus/u/SocialPlus_Support)\
**Post date:** [March 7, 2024, 7:31am UTC](https://forum.social.plus/t/cannot-find-type-sessionhandler-in-scope/1172/6 "2024-03-07T07:31:12Z")

</div>

Thank you for the update. We will continue to provide assistance in the new topic that your team has created.
