iMessage App Extention : Active conversation is not getting for draft - ios

self.activeConversation!.insertText(newMessage) { error in
if let error = error {
print(error)
}
}
Unable to get the Active conversation for draft messages as method is not getting called.

Related

How to understand a playlist is an editable one in MusicKit? (iOS 16)

How can I only retrieve playlists that are editable? Or in other words how can I retrieve playlists that are only created by the user?
We can get the playlists of the user by the following code block:
var request = MusicLibraryRequest<Playlist>()
request.sort(by: \.lastPlayedDate, ascending: false)
let response = try await request.response()
Also, we can add a track to the playlist with the following code block:
TASK {
do {
try await MusicLibrary.shared.add(track, to: playlist)
} catch (let error) {
print(error)
}
}
However not all playlists are editable. For instance if the playlist created by Apple or another Apple Music user, we receive an error while adding track to the playlist because we don't have a permission to do it.
I receive the following error:
Error Domain=MPErrorDomain Code=5 "The requested action is not supported" UserInfo={NSLocalizedDescription=The requested action is not supported}

How to run a function after setupIntentConfirmation succeeds?

I can successfully create and confirm a setupIntent. After the user enters his credit card details and presses the "confirm" button, his payment method is successfully attached to their stripe customer account. However, when the setupIntent is confirmed, I'd like to run a function on my client to send the user to a different screen.
This is where I check the completion of the setupIntentConfirmation. The print statement shows in the console but for some reason, my function is not running.
func onCompletion(status: STPPaymentHandlerActionStatus, si: STPSetupIntent?, error: NSError?) {
self.setupIntentStatus = status
self.error = error
if status == .succeeded {
print("succeeded")
setIsVerifiedToTrue()
}
}
Here is the function I am trying to run:
func setIsVerifiedToTrue() {
let ref = FirebaseReferenceManager.root.collection(FirebaseKeys.CollectionPath.requirements).document(Auth.auth().currentUser!.uid)
ref.updateData([FirebaseKeys.RequirementsFieldPath.verified : true]) { error in
if let error = error {
print("Error updating document: \(error)")
} else {
print("isVerified set to true")
}
}
}
any help would be very much appreciated! :)

callkit reload extension in ios

i am creating app like as trucaller. Everything is completed, only one issue remaining. issue is that how to reload application extension after add new contact number from server in app. first of all, i enter some static number in the array then after i store it in userdefault. i got this by app-groups functionality. i want that when user synchronize their contact in my application, i want reload contact list.
this is my code
manager.reloadExtension(withIdentifier: extensionIdentifer, completionHandler: { error in
print("error \(error?.localizedDescription)")
if let _ = error{
print("A error \(error?.localizedDescription as String!)");
}
})
this is give me error like below
"sqlite3_step for query 'INSERT INTO PhoneNumberBlockingEntry
(extension_id, phone_number_id) VALUES (?, (SELECT id FROM PhoneNumber
WHERE (number = ?)))' returned 19 (2067) errorMessage 'UNIQUE
constraint failed: PhoneNumberBlockingEntry.extension_id,
PhoneNumberBlockingEntry.phone_number_id'"
Jaydeep: Call your new contact web service or synchronize contacts in application and just reload extension as -
CXCallDirectoryManager.sharedInstance.getEnabledStatusForExtension(withIdentifier: "com.compname.sampleapp", completionHandler: { (enabledStatus,error) ->
Void in if let error = error {
print(error.localizedDescription)
}
CXCallDirectoryManager.sharedInstance.reloadExtension(withIdentifier:"com.compname.sampleapp", completionHandler: {
(error) ->
Void in if let error = error {
print(error.localizedDescription)
}
DispatchQueue.main.async {
self.hud?.hide(animated: true)
}
})
print("No error")
})
Let me know still issue getting. I have done this and working fine.

How can I get started with Quickblox API and Swift?

I am trying to develop a very simple chat application using quickblox and swift.
Knowing that there are few tutorials online that try to explain the process, I started with creating a user in the application dashboard and getting its credentials to initiate the connection. (I am certain that the user credential are correct and the dashboard is correctly set as I have followed this tutorial)
Here is the Application view controller:
import UIKit
import Quickblox
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let user = QBUUser()
user.id = 29777469
user.password = "tahrisqalli"
QBChat.instance().connect(with: user) { (error) in
if error != nil {
print("error: \(error)")
}
else {
print("login to chat succeeded")
}
}
}
}
and following is the error I get telling me that I did not connect successfully.
2017-07-11 11:33:50.837 QuickbloxTutorial[1045:24701] [ChatService] Connecting to Chat, host: chat.quickblox.com, user JID: 29777469-0#chat.quickblox.com/DCB0A1F4-3A56-49AD-9639-8C2A6BBE7B08
2017-07-11 11:33:52.042 QuickbloxTutorial[1045:24711] [ChatService] Stream isSecure: YES
2017-07-11 11:33:52.658 QuickbloxTutorial[1045:24722] [ChatService] Stream did connect, supportsStartTLS: YES
2017-07-11 11:33:52.824 QuickbloxTutorial[1045:24722] [ChatService] Did not authenticate, error: <failure xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><not-authorized/></failure>
error: Optional(Error Domain=com.quickblox.chat Code=401 "<failure xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><not-authorized/></failure>" UserInfo={NSLocalizedDescription=<failure xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><not-authorized/></failure>})
2017-07-11 11:33:52.842 QuickbloxTutorial[1045:24722] [ChatService] Did disconnect
First of all, you have to log in with a user.
After this, You can connect with chat and it is best for you to use ServicesManager class that manage session automatically.
let loginUser = QBUUser()
loginUser.id = 29777469
loginUser.password = "tahrisqalli"
ServicesManager.instance().authService.logInWithUser(loginUser, completion: { (response, qbUser) in
if qbUser != nil {
ServicesManager.instance().chatService.connectWithCompletionBlock { (error) in
if error != nil {
print("user not connected error: ",error?.description)
} else {
//user connect successfully
}
}
print(qbUser)
} else {
print(response.error?.description)
}
})

LayerKit's newConversationWithParticipants always throws FMDatabase "not an error" on first call

I'm using LayerKit 0.17.3 with Swift and newConversationWithParticipants always throws an error on first time, with the domain set to FMDatabase and with a "not an error" error. Any subsequent call gets expected result.
Initial error:
Error with creating LYRConversation: Error Domain=FMDatabase Code=0 "not an error"
UserInfo={NSLocalizedDescription=not an error}
Subsequent errors: (desired)
Error with creating LYRConversation: Error Domain=com.layer.LayerKit.Errors
Code=1013 "A conversation with a distinct participant list already exists
for participants [...]
Here's the function to find/create the conversation:
#IBAction func didTapCompose(sender: AnyObject) {
var conversation : LYRConversation?
// create ATLConversationViewController
let controller = ConversationViewController(layerClient: self.layerClient)
controller.hidesBottomBarWhenPushed = true;
// get recipient (user objectID) from member object
let recipient = member.objectForKey(GlobalConstants.Parse.UserKey)?.objectId!
// create set for newConversationWithParticipants
let participants : Set = [recipient!]
do {
try conversation = layerClient.newConversationWithParticipants(participants, options: nil)
controller.conversation = conversation
} catch {
print("Error with creating LYRConversation: \(error)")
}
self.navigationController!.pushViewController(controller, animated: true)
}
Support over at Layer.com stated at this is a bug and will be fixed in the next release.
This is still broken, the above answer says the version is at 0.17.4, but cocoapod is still at 0.17.3 https://cocoapods.org/?q=layerkit
It is still breaking on my project
Layer does not create conversations with same participants by default.
You have to set the distinct flag to false in options while creating.
Tested with layerkit 0.17.4.
options = [LYRConversationOptionsDistinctByParticipantsKey : false]
let conversation = layerClient.newConversationWithParticipants(participants, options: options)

Resources