Hi,
My project is already setup with firebase and I want to add Chat SDK.
I am using custom login so I setup the ChatSDK in app delegate according to documents. My code is as under.
let config = BConfiguration.init();
config.rootPath = "test"
// Configure other options here...
config.allowUsersToCreatePublicChats = true
BChatSDK.initialize(config, app: application, options: launchOptions)
After that I am login to the firebase and ChatSDK as under
BIntegrationHelper.authenticate(withToken: Auth.auth().currentUser?.refreshToken)
BIntegrationHelper.updateUser(withName: userName, image: nil, url: nil)
I observed that there is no database entry in firebase after login so I implemented following method.
_ = BChatSDK.core()?.pushUser()?.thenOnMain({ thread in
// Success
return nil
}, { error in
// Failure
print(error.debugDescription)
return error
})
I am getting error in above case and no database entries on Firebase.
I am opening chatviewcontroller on button click as Under
let wrapper2 : CCUserWrapper = CCUserWrapper.user(withEntityID: selectedID)
wrapper2.metaOn()
// wrapper2.onlineOn()
let user2 : PUser = wrapper2.model()
if (selectedName.count > 0 )
{
user2.setName(selectedName)
}
else
{
user2.setName("No name set")
}
wrapper2.push() //database entry in users table but not on indices
// BChatSDK.contact().addContact(user2, with: bUserConnectionTypeContact)
let wrapper1 : CCUserWrapper = CCUserWrapper.user(withEntityID: myID
)
wrapper1.metaOn()
wrapper1.onlineOn()
let user1 : PUser = wrapper1.model()
if (myName.count > 0 )
{
user1.setName(myName)
}
else
{
user1.setName("No name set")
}
wrapper1.push() // This push creates database users entry but not in indices.
let users : Array = [user1, user2]
_ = BChatSDK.core().createThread(withUsers: users , threadCreated: {(error: Error?, thread:PThread?) in
if ((error) != nil)
{
print(error.debugDescription)
}
else
{
let cvc = BChatSDK.ui().chatViewController(with: thread)
self.navigationController?.pushViewController(cvc!, animated: true)
}
}) }
My app crashed in above case.
Stack trace is as under
018-11-30 03:41:31.296060+0500 ModoBuddy[73840:7171000] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil'
*** First throw call stack:
(
0 CoreFoundation 0x00000001094ea1bb __exceptionPreprocess + 331
1 libobjc.A.dylib 0x0000000108a84735 objc_exception_throw + 48
2 CoreFoundation 0x00000001094364ec _CFThrowFormattedException + 194
3 CoreFoundation 0x0000000109412775 -[__NSArrayM insertObject:atIndex:] + 1269
4 ChatSDK 0x00000001059d5893 -[BAbstractCoreHandler fetchThreadWithUsers:] + 211
5 ModoBuddy 0x0000000103b06b3c -[BFirebaseCoreHandler createThreadWithUsers:name:threadCreated:] + 140
6 ModoBuddy 0x0000000103b071ec -[BFirebaseCoreHandler createThreadWithUsers:threadCreated:] + 124
7 ModoBuddy 0x0000000103a72342 $S9ModoBuddy28FriendsProfileViewControllerC10actMessageyyypF + 2466
8 ModoBuddy 0x0000000103a729cc $S9ModoBuddy28FriendsProfileViewControllerC10actMessageyyypFTo + 76
9 UIKitCore 0x000000010d87aecb -[UIApplication sendAction:to:from:forEvent:] + 83
10 UIKitCore 0x000000010d2b60bd -[UIControl sendAction:to:forEvent:] + 67
11 UIKitCore 0x000000010d2b63da -[UIControl _sendActionsForEvents:withEvent:] + 450
12 UIKitCore 0x000000010d2b531e -[UIControl touchesEnded:withEvent:] + 583
13 UIKitCore 0x000000010d8b60a4 -[UIWindow _sendTouchesForEvent:] + 2729
14 UIKitCore 0x000000010d8b77a0 -[UIWindow sendEvent:] + 4080
15 UIKitCore 0x000000010d895394 -[UIApplication sendEvent:] + 352
16 UIKit 0x000000012a1b6183 -[UIApplicationAccessibility sendEvent:] + 85
17 UIKitCore 0x000000010d96a5a9 __dispatchPreprocessedEventFromEventQueue + 3054
18 UIKitCore 0x000000010d96d1cb __handleEventQueueInternal + 5948
19 CoreFoundation 0x000000010944f721 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
20 CoreFoundation 0x000000010944ef93 __CFRunLoopDoSources0 + 243
21 CoreFoundation 0x000000010944963f __CFRunLoopRun + 1263
22 CoreFoundation 0x0000000109448e11 CFRunLoopRunSpecific + 625
23 GraphicsServices 0x0000000110e2b1dd GSEventRunModal + 62
24 UIKitCore 0x000000010d87981d UIApplicationMain + 140
25 ModoBuddy 0x0000000103ada7c4 main + 68
26 libdyld.dylib 0x000000010abed575 start + 1
27 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Kindly help me out
thanks
Hi,
My project is already setup with firebase and I want to add Chat SDK.
I am using custom login so I setup the ChatSDK in app delegate according to documents. My code is as under.
After that I am login to the firebase and ChatSDK as under
I observed that there is no database entry in firebase after login so I implemented following method.
I am getting error in above case and no database entries on Firebase.
I am opening chatviewcontroller on button click as Under
My app crashed in above case.
Stack trace is as under
Kindly help me out
thanks