In our native iOS app, I included the ServiceSDK using Cocoapods. Referring to https://developer.salesforce.com/docs/atlas.en-us.noversion.service_sdk_ios.meta/service_sdk_ios/servicesdk_ios_dev_guide.htm
Now, I want to fetch articles from Salesforce. So, I want to use the KnowledgeManager class. But as a prequisite, I need to establish the SCSServiceConfiguration object. This requires a CommunityURL.
We do not use communities in our org.
So, I use the current user's login credentials as directed here: https://developer.salesforce.com/docs/atlas.en-us.noversion.service_sdk_ios.meta/service_sdk_ios/knowledge_authenticated_user.htm
Next step, I try to fetch the data categories as directed here: https://developer.salesforce.com/docs/atlas.en-us.noversion.service_sdk_ios.meta/service_sdk_ios/ios_cache_offline.htm
I have 2 errors in XCode:
[general] Community URL appears to be configured incorrectly.
Please refer to the Service SDK Developer's Guide for more information on configuring your organization.
https://developer.salesforce.com/docs/atlas.en-us.noversion.service_sdk_ios.meta/service_sdk_ios/error_community.htm
load failed with error Error Domain=NSURLErrorDomain Code=-1002 "unsupported URL" UserInfo={NSLocalizedDescription=unsupported URL, NSErrorFailingURLStringKey=//test.salesforce.com/services/data/v44.0/support/dataCategoryGroups?sObjectName=KnowledgeArticleVersion&topCategoriesOnly=false, NSErrorFailingURLKey=//test.salesforce.com/services/data/v44.0/support/dataCategoryGroups?sObjectName=KnowledgeArticleVersion&topCategoriesOnly=false, _NSURLErrorRelatedURLSessionTaskErrorKey=(
"LocalDataTask <E6B620D0-AC3F-4FDF-996D-317D17AB2DEE>.<2>"
), _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <E6B620D0-AC3F-4FDF-996D-317D17AB2DEE>.<2>, NSUnderlyingError=0x600000047a80 {Error Domain=kCFErrorDomainCFNetwork Code=-1002 "(null)"}} [-1002]
Why would Salesforce make it mandatory to have Communities in order for us to access Knowledge from Mobile SDK?
Am i missing something? Is there a cleaner way to include and use the ServiceSDK?
**UPDATE: ** I was able to get the data categories as an authenticated user. Below is the code that worked:
In AppDelegate, didFinishLaunching API:
AuthHelper.loginIfRequired({
let identity: UserAccountIdentity = UserAccountManager.shared.currentUserAccountIdentity!
let account: UserAccount = UserAccountManager.shared.userAccount(for: identity)!
// Create auth settings object from SFUserAccount
self.scsAuthSettings = SCSAuthenticationSettings(mobileSDK: account)
//Set the Authentication Settings to the ServiceCloud object.
ServiceCloud.shared().setAuthenticationSettings(self.scsAuthSettings, forServiceType: SCServiceType.knowledge, completion: nil)
})
However, I am still not able to fetch articles. The code I have for fetching the articles is as below:
let km = KnowledgeManager.default
let query = MutableArticleQuery()
query.categories = categories
query.queryMethod = .at
query.pageSize = 2
km.fetchArticles(with: query) { (articles, error) in
if error != nil {
print(error?.localizedDescription ?? "")
}
completion(articles)
}
There is no error. But the articles always has 0 records.