# iOS: Correct initialisation

**URL:** <https://community.sendbird.com/t/ios-correct-initialisation/5967>\
**Category:** iOS\
**Tags:** ios\
**Created:** [November 16, 2022, 12:45pm UTC](https://community.sendbird.com/t/ios-correct-initialisation/5967 "2022-11-16T12:45:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![margaret](https://avatars.discourse-cdn.com/v4/letter/m/a88e57/32.png) [@margaret](https://community.sendbird.com/u/margaret)\
**Post date:** [November 16, 2022, 12:45pm UTC](https://community.sendbird.com/t/ios-correct-initialisation/5967/1 "2022-11-16T12:45:04Z")

</div>

SendbirdUI Version: 3.2.2  
✋

I have had problems with the initialization of SendbirdUI.  
I followed the documentation on how you should initialize Sendbird using SPM but I saw that the initialization produces crashes in our production version.

I am wondering if it is a bad idea to initialize SendbirdUI and SendbirdChat at the same time.

```swift
        SendbirdUI.initialize(applicationId: applicationID) { [weak self] error in
            if let error = error {
                print("SendbirdUI initialisation: \(String(describing: error))")
            }
            SendbirdUI.setLogLevel(.none)
        }

       let initParams = InitParams(applicationId: applicationID, logLevel: .none)
        if let error = SendbirdChat.initializeSynchronously(params: initParams) {
            print("SendbirdChat initialisation: \(String(describing: error))")
        }

```

I decided to go this way because in some of the tests I did with the SendbirdUI initiation, some users had no channel available and all their messages were lost but by adding the SendbirdChat initiation this problem was solved.

---

<div class="post-metadata">

**Author:** ![plopes](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/plopes/32/1728_2.png) [@plopes](https://community.sendbird.com/u/plopes)\
**Post date:** [December 26, 2022, 5:05pm UTC](https://community.sendbird.com/t/ios-correct-initialisation/5967/2 "2022-12-26T17:05:55Z")

</div>

@margaret what kind of crashes were you having?  
I’m also having some random issue on production where I have users with a crash on SendbirdChat `Database.swift`.

---

<div class="post-metadata">

**Author:** ![margaret](https://avatars.discourse-cdn.com/v4/letter/m/a88e57/32.png) [@margaret](https://community.sendbird.com/u/margaret)\
**Post date:** [December 30, 2022, 12:01pm UTC](https://community.sendbird.com/t/ios-correct-initialisation/5967/3 "2022-12-30T12:01:05Z")

</div>

Hi @plopes,  
My error was in `SendbirdManager.initializeSendbirdChat()`

---

<div class="post-metadata">

**Author:** ![Ashwani\_Kumar](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/ashwani_kumar/32/4110_2.png) [@Ashwani\_Kumar](https://community.sendbird.com/u/Ashwani_Kumar)\
**Post date:** [June 5, 2023, 6:57am UTC](https://community.sendbird.com/t/ios-correct-initialisation/5967/4 "2023-06-05T06:57:24Z")

</div>

@plopes were you able to tackle this crash?

---

<div class="post-metadata">

**Author:** ![plopes](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/plopes/32/1728_2.png) [@plopes](https://community.sendbird.com/u/plopes)\
**Post date:** [July 3, 2023, 7:24am UTC](https://community.sendbird.com/t/ios-correct-initialisation/5967/5 "2023-07-03T07:24:32Z")

</div>

According to an email thread that I’ve with sendbird this was fixed in Sendbird Chat v4.8.1  
I haven’t try this as I’ve been off and will do this update in our next release
