Closed sunilhs1986 closed 7 years ago
Hi @sunilhs1986,
This should be easy to achieve, you'll need follow a few steps:
Things to watch out for:
Let me know if this helps get you on the right path,
Simon
Hi Simon,
Thanks for your response.
I integrated the way you explained above, but its crashing.
Steps: Step 1. I open the app which i have built and then login to chat sdk and i was able to message to the registered user. Step 2. Navigate to a different section. Step 3. I open the chat ui and try to message the user and click send button it crashes.
Terminating app due to uncaught exception 'NSObjectInaccessibleException', reason: 'CoreData could not fulfill a fault for '0xd000000000040002 <x-coredata://95E37307-1CBD-425C-828B-D8317E4A3CFB/CDThread/p1>''
Could you please help me on this. Thanks in advance.
Regards Sunil
Hi @sunilhs1986,
Can you add the code showing how you are loading the Chat UI?
I would do it in the following way:
Making this change should require very little code. If your Chat SDK was working correctly before then loading up a view controller from somewhere else should not cause any issues.
It is worth remembering that the app stores the user's conversations on it so the conversations might be showing up without the app being correctly connected to Firebase. This could mean you are trying to send a message without being logged in.
I would open up Firebase and ensure that the user is correctly logged in, you can do this by changing some information on the user profile and seeing the search index updating.
Otherwise though without actively looking at your project it is very difficult to know exactly what is going on. If you wanted to buy some priority support then I could have a look at this for you and send you and put together an example project with this functionality, let me know if this is something you would be interested in.
Simon
Hi Simon,
i am using the below code for launching fire base ui.
[BNetworkManager sharedManager].a = [[BFirebaseNetworkAdapter alloc] init];
// Set the default interface manager
[BInterfaceManager sharedManager].a = [[BDefaultInterfaceAdapter alloc] init];
[BStorageManager sharedManager].a = [[BCoreDataManager alloc] init];
// This is the main view that contains the tab bar
UIViewController * mainViewController = [[BAppTabBarController alloc] initWithNibName:Nil bundle:Nil];
// Set the login screen
[BNetworkManager sharedManager].a.auth.challengeViewController = [[BLoginViewController alloc] initWithNibName:Nil bundle:Nil];
NSLog(@"%d",[BNetworkManager sharedManager].a.auth.userAuthenticated);
[appdelegate.window setRootViewController:mainViewController];
For priority support is there any cost involved ?
Regards Sunil
Hi @sunilhs1986,
You can get information on priority support on our website here
I would first recommend checking the Chat SDK is working on your accounts:
For the third step it should be easy, when you first login it might be that your user isn't logged in. This should raise the BLoginView as a challenge view. Once you login you can load any view by initialising it and presenting it.
For example - in this example I have subclassed the BContactsViewController - I then just load and show it as normal. It will then show the contacts view controller as expected and can be modified within the subclass:
UIViewController * vc = [[BCustomContactsViewController alloc] init];
[self.navigationController pushViewController:vc animated:YES];
Let me know if this helps,
Simon
Hi Simon,
I would like to know if i buy a priority support for 1 hour ($79.99) will be you sending us a sample project with our use case.
Also is this priority support is one time support for 1 hour or something else. Let me know if you can support us with a sample code and will pay this cost immediately.
Regards Sunil
Hi @sunilhs1986,
How we support is really up to you. If you want you can send us a copy of your project and we can spend an hour adding the Chat SDK (if you do decide to go for this option please ensure your project compiles and runs correctly, it would be annoying to waste time troubleshooting this option). Otherwise you can let me know exactly what you are after and I can put together a test project and documentation for it.
In answer to your second point, when you buy an hour support it is a one time support, depending on the issue you are facing will depend on how much help we can provide within the support period.
In the case of this ticket I would expect do to the following steps providing support:
I'll then provide these test documents to you via a dropbox link (let me know if a different way would be more convenient).
If you do buy the priority support please comment here so I can allocate some time to get this done as soon as possible and also email me a detailed description of the exact problems and fixes you are looking for. This will help me make best use of my time while supporting this issue,
Simon
Hi Simon,
I have purchased 1 hour support for Chat SDK and attached is the receipt for same.
I have created a sample project with Chat SDK frame work u can run the project and you will see 2 buttons on click of Chat SDK button i would like to load the chat feature.
You can refer to MenuViewController.m class for button action(chatPressed) for chat event. If u have any difficulties in running the project u can create a sample project with similar ui and send us.
Let us know if you need anything else.
Thanks in advance.
Regards Sunil
Hi @sunilhs1986,
I have created the project and gone through the following steps:
This gets us to the point where the project runs and the Chat SDK opens immediately. At this stage I also load the Chat SDK and ensure that logging on correctly connects me with the database.
The importance of following these steps until now is so that we ensure the Chat SDK is configured correctly and is ready to be used.
USING THE CHAT SDK
We are now ready to start using the Chat SDK. The first thing we need to worry about is the login flow. A user has to login to be able to use the Chat SDK. You can put the login flow where ever you like - you just need to make sure that the user HAS to login if they want to get to the chat. We also have the Chat SDK set up flow, this is best kept in the app delegate to ensure it is run correctly.
In the example project I have added a line in the BViewController.m:
// De-comment for login on first screen
If you de-comment the viewDidAppear and showLoginScreen functions on this screen then the app will prompt you to login as soon as you load the app. These functions have been copied directly from the BAppTabBarViewController. All it does it raise the login screen if there is not a logged in user. This can be called - or checked from anywhere.
Loading the Chat SDK somewhere else
I assumed this wasn't the method you were after so I have commented this out for now. You can now see two buttons: Chat SDK (load the Chat SDK) and thread view (load a thread view - you must be logged in for this to work correctly).
Loading the ChatSDK The code to load the Chat SDK is very simple:
- (IBAction)chatSDKButtonPressed:(id)sender {
if (!_mainViewController) {
_mainViewController = [[BAppTabBarController alloc] initWithNibName:nil bundle:nil];
}
[self presentViewController:_mainViewController animated:YES completion:nil];
}
(you can see this in the chatSDKButtonPressed function)
If you load up the project and click the ChatSDK button it will load up the Chat and immediately prompt the user to sign in.
Well done you have now successfully loaded the Chat SDK. The important thing now is to work out the Chat SDK flow to allow users to return to your main app and exit the Chat area.
This leads me onto another important point, you should never be directly changing code inside the Chat SDK, instead you should always subclass to ensure that you can update with the latest Chat SDK code. It also means any modifications won't break other functionality in the Chat SDK.
You will see that I have changed the challenge view controller to the BSunilLoginViewController subclass and in this view I have added a back button to close the Chat SDK.
Now we look at getting back from the Chat SDK once logged in. Load up the project, click Chat SDK then login (just make up a password and user name then click register) you will access the main tab view of the Chat SDK. Click the public threads or contact tab and you'll see I have added a "back to app" button. This will take you back to the main view.
If you look in the code you'll see I have subclassed some of these tabs for you:
BSunilPrivateThreadsViewController BSunilContactsViewController
This means that they have the same functionality as the original plus a bit I added into the project.
If you look in these view controllers you can see that we only need to dismiss the Chat SDK to get rid of it and return to the main view:
[self dismissViewControllerAnimated:YES completion:nil];
You will also notice I subclassed the BDefaultInterfaceAdapter. This was so I could set the tabBar tabs without changing the Chat SDK code:
// Set the default interface manager
[BInterfaceManager sharedManager].a = [[BSunilInterfaceAdapter alloc] init];
In the app delegate I set the new interface manager
-(UIViewController *) publicThreadsViewController {
return [[BSunilPublicThreadsViewController alloc] init];
}
-(UIViewController *) contactsViewController {
return [[BSunilContactsViewController alloc] init];
}
I then override the tab methods to return the subclasses.
Finally:
Accessing the threads view
MAKE SURE YOU ARE LOGGED IN. Then click on the threads button in the main view. This will load up the Public threads view controller. This is to show how easy it is to load a Chat SDK view controller from anywhere in the app. This would be useful if you want to login the user in immediately then add the threads view controller in a custom area of your app (or add any Chat SDK view controller in an area of your app).
Conclusion
To conclude, completing this up took substantially longer than a single hour. Because of this, and not wanting to leave it half finished I had to write up this documentation much faster than I would have liked. It should be completed though and has been tested so should all be in working order. You can access the project at this URL: https://www.dropbox.com/sh/j5jsbrv0hi4r1ko/AAAJeJ08fPKyMH_wBsgdh31Fa?dl=0
Please download it immediately as the URL will only be maintained for about a week.
If you need further help then I can answer basic questions on this in this thread - if you want me to continue working on the documentation and project examples I can provide more priority support if you want it.
Please let me know how you get on, once you get the hang of the Chat SDK it is very easy to use and manipulate so hopefully this tutorial will get you on your way.
Simon
Hi Simon,
Thanks for you support and the sample project you have sent.
I tried to build the project i am getting the below error. Can u please check it ?
/Users/sunil.h.shivamurthy/Library/Developer/Xcode/DerivedData/TestSunilProject-gzpqdazwgryzuqemjokziaotttih/Build/Intermediates/TestSunilProject.build/Debug-iphonesimulator/TestSunilProject.build/Script-AD62BC906B707396BD9C9A04.sh: line 2: /Users/sunil.h.shivamurthy/Downloads/Sunil/TestSunilProject/Pods/Target Support Files/Pods-TestSunilProject/Pods-TestSunilProject-frameworks.sh: Permission denied
It says permission denied.
Regards Sunil
Hi @sunilhs1986,
Can you confirm how you are running it? Are you loading up the file as shown below?
The project is working for me from the Dropbox file just fine
If this doesn't work it might be worth changing the console to the project file and calling pod update to ensure the pods are up to date but they should be.
Let me know if you continue to have issues as it should be working fine,
Simon
Hi Simon,
I was able to run the project now and pod update worked but its crashing in BCoreDataManager.m class in this method "NSURL * momURL = [NSURL fileURLWithPath:path];"
(NSManagedObjectModel *)managedObjectModel {
if (!_managedObjectModel) { NSBundle * bundle = [NSBundle bundleWithFramework:@"ChatSDKCoreData" name:@"ChatCoreData"];
NSString * path = [bundle pathForResource:@"ChatSDK" ofType:@"momd"];
NSURL * momURL = [NSURL fileURLWithPath:path];
_managedObjectModel = [[NSManagedObjectModel alloc] initWithContentsOfURL:momURL];
}
return _managedObjectModel; }
Regards Sunil
Hey @sunilhs1986,
Can you confirm a few things:
Simon
Hi Simon,
Yes i deleted the project and compiled in simulator. Here is error i am getting when application loads.
Applications/Xcode 8.3.3.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/AssetsLibraryServices.framework/AssetsLibraryServices (0x11a083cc0) and /Applications/Xcode 8.3.3.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/PhotoLibraryServices.framework/PhotoLibraryServices (0x119e9a6f0). One of the two will be used. Which one is undefined.
2017-08-31 15:57:49.715 TestSunilProject[35218]
Hi Simon,
I was finally able to run the project in simulator, but in device its crashing below is the error log.
dyld: Library not loaded: @rpath/Firebase.framework/Firebase Referenced from: /private/var/containers/Bundle/Application/8591F32F-203B-4E0D-8B60-FE40914028F4/TestSunilProject.app/Frameworks/ChatSDKFirebaseAdapter.framework/ChatSDKFirebaseAdapter Reason: image not found
Regards Sunil
Hi @sunilhs1986,
If you can get it to run in the simulator that should be fine. The example project is only to show you how to load the Chat SDK in different areas of your actual project. If you work through the code and the documentation you should be able to copy it into your project to get the functionality you are after.
Simon
Hi Simon,
I just ran the sample code u shared in device, could you please let me know why its crashing.
Regards Sunil
Hi @sunilhs1986,
I don't know why the sample code is crashing on your device, the sample project is designed to show you how to architect the Chat SDK code. It currently compiles and runs on both my devices and my simulator.
You previously mentioned the project was running on a simulator, this should be enough to understand the flow of the test app and incorporate it into your project.
Simon
Hi Simon,
I have tried all possible ways but its not loading on device. i have integrated the chat sdk into my project and still the issue persists. Below is the error which i am getting.
dyld: Library not loaded: @rpath/Firebase.framework/Firebase Referenced from: /private/var/containers/Bundle/Application/EA33044D-4EAE-4523-945A-A0D4E08AD370/SampleApp.app/Frameworks/ChatSDKFirebaseAdapter.framework/ChatSDKFirebaseAdapter Reason: image not found
Please help us on this.
Regards sunil
Hi @sunilhs1986,
I won't be able to troubleshoot this issue without having your project and manually adding the Chat SDK to it myself. For this you would need to purchase more priority support or buy the integration package.
This seems to be an issue with your project or set up instead of a problem with the Chat SDK which runs and compiles fine when downloaded.
Simon
Hi Simon,
Thanks for getting back. Actually, we develop white label Apps for lawyers. We have over 300 law firm clients. We will be implementing your chat solution on all their Apps and our future clients.
We agree to pay your company $100 for each lawyer client App (iPhone and Android). But first, we need our pilot client to test the chat solution successfully.
Hence, I would request you to resolve the bugs in the sample code which u have sent and send us the working code.
I have tried all possible ways but its not loading on device. Below is the error which i am getting.
dyld: Library not loaded: .framework/Firebase Referenced from: /private/var/containers/Bundle/Application/EA33044D-4EAE-4523-945A-A0D4E08AD370/SampleApp.app/Frameworks/ChatSDKFirebaseAdapter.framework/ChatSDKFirebaseAdapter Reason: image not found
Please help us on this.
Thanks, Sunil
Hi Sunil,
When I added the latest version of the library using the instructions outlined here the project complied just fine. Here's the updated project: Sunil.zip
When you get it you should run pod install
then find the setup_links.sh script which is inside the TestSunilProject and run sh setup_links.sh
. This will setup the symbolic links to the Firebase Adapter.
Thanks,
Ben
Thank you Ben for timely help and support , the new code which you sent works perfectly on device.
Regards Sunil
It would be soooo helpful if this could be explained fully in Swift
Hi Simon,
I was finally able to run the project in simulator, but in device its crashing below is the error log.
dyld: Library not loaded: @rpath/Firebase.framework/Firebase Referenced from: /private/var/containers/Bundle/Application/8591F32F-203B-4E0D-8B60-FE40914028F4/TestSunilProject.app/Frameworks/ChatSDKFirebaseAdapter.framework/ChatSDKFirebaseAdapter Reason: image not found
Regards Sunil
can you please help me understand what you did to fix the issue of initFileURLWithPath nil string parameter.
Hi,
I am trying to integrate the chat sdk into our project, but i want to setup in different view controller rather than appdelegate has we have other features in app as well.
Regards Sunil