How to get the sent emails in ios - ios

I have a requirement that I have to send an email and show them in sent items. Using iOS mail API. I can send the email. But I am not able to retrieve the sent items.
Is there any possible way to store the sent email and show them in sent items with all the details like ( to, message body,...) ?
Is it possible to fetch any information from MFMailComposeViewController in the delegate methods?
­-(void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:
(MFMailComposeResult)result error:(NSError *)error {
// Any way to fetch sent mail info
}

You can set MFMailComposeViewControllerDelegate in your code. This delegate has a method
- mailComposeController:didFinishWithResult:error:
which sends the results enum through which you can figure out if the mail was sent or not. Then you can save your email message/subject and show the user list of emails they have sent.

Related

Get Only Unread Messages from QuickBlox?

I had integrated QuickBlox SDK in my chat application.
I am Bit frustrated with an issue of unread messages or say offline messages.
In offline messages QuickBlox do send the push notification. But some where it gets skipped to store at app side.
Like say if i got notification of 25 messages and i click on one of message from notification and app gets open but how can i get those 24 unread(Offline) messages.
There are few methods given by QuickBlox to retrieve messages.
For Group
[[QBChat instance] createOrJoinRoomWithJID:room.JID membersOnly:YES persistent:YES historyAttribute:#{#"maxstanzas": count}]; // Where count is the unread messages count which i get from the `QBChatDialog`, And this code gives me unread messages from the `XMPP` server.
Private and Group both from QuickBlox
NSMutableDictionary *extendedRequest = [NSMutableDictionary new];
extendedRequest[#"limit"] = #(limit);
if (offset) {
extendedRequest[#"skip"] = #([offset integerValue]);
}
extendedRequest[#"sort_desc"] = #"date_sent";
[QBChat messagesWithDialogID:dialogID extendedRequest:extendedRequest delegate:self];
Both of above method return me the messages from last. But some of messages in between gets skipped. So how can i get those perticular messages.
By short and simple i just want the messages that are unread without passing its count as count gives the messages that are from last.
So is there any method that QuickBlox have to retrieve only unread message.
At this moment you can save a datetime where your application has been closed( or moved to background ). Then when you receive push, you can load dialogs from previously saved datetime.

When both users are in chat room, messages are still marked unread

I'm having some trouble with Quickblox chat. Whenever two users are both logged in and both joined in the same chat room, messages that are sent between the two users are not marked as read. When I back out of the room to the dialogs list and the dialogs are refreshed, it says that there are unread messages even though I was in the room and I was receiving the messages live.
Is there a certain call that I must make to let it be known that the received messages should be marked as read? I am developing in iOS.
Thanks.
User has to read message to mark it as read
NSString *dialogID = #"53d10eede4b02f496c21549f";
NSArray *mesagesIDs = #[#"53aabe15e4b077ddd43e7fd3", #"53aabe15e4b077ddd43e7fd7"];
[QBChat markMessagesAsRead:mesagesIDs dialogID:dialogID delegate:self];
In iOS you can use:
QBRequest.markMessagesAsRead(Set<String>?, dialogID: String, successBlock:
{
(QBResponse) in code
})
{
(QBResponse) in code
}

Get presence information from PubNub

I am trying to setup a two person chat with PubNub. I am having trouble differentiating between the clients.
I signed up for Presence in the admin console and have enabled the feature like this:
[PubNub subscribeOnChannel:[PNChannel channelWithName:#"my_channel" shouldObservePresence:YES]];
I have an observer setup like this:
[[PNObservationCenter defaultCenter] addMessageReceiveObserver:self withBlock:^(PNMessage *message) {
//identification code here
}];
I know the PNMessage contains the channel and message content but how do I get the clientIdentifier of the device that sent a message received?
According their docs and iOS SDK repo which is here: https://github.com/pubnub/objective-c/tree/master/iOS#publishing-messages
Messages can be an instance of one of the following classed: NSString,
NSNumber, NSArray, NSDictionary, or NSNull.
You can send other object types as the message (rather than just a string as you are doing). You can simply send a dictionary object with a senderID key that the subscribers can then read.
If you want to use an observer for Presence events, here is an example of using addPresenceEventObserver:withBlock:
https://github.com/pubnub/objective-c/blob/master/iOS/HOWTO/SimpleSubscribe/PubNubDemo/ViewController.m#L39
to log UUIDs, (also know as the client identifier):
https://github.com/pubnub/objective-c/blob/master/iOS/HOWTO/SimpleSubscribe/PubNubDemo/ViewController.m#L52
Is this what you are trying to do?

Send an email from my app without using MFMailComposeViewController

Is it possible to send an automatically generated email using my own email address to another email address of mine by clicking a button?
I tried to use MFMailComposeViewController but another view appeared. Can I do it without this view?
You can do it only by creating own server-side mailer. On button clicking you have to send request with all needed data (email address, body, subject, etc) and server will send mail.
If You want send directly from app - MFMailComposeViewController is the only LEGAL way
By default in iOS you can only use the MFMailComposeViewController, which uses the user's mail account. Therefore you cannot send fully automated mail messages (the user allways has to confirm/cancel).
libMailCore is a great iOS framework which allows you to generate and send mails without any user interferance. In that case you'll be using your own server/credentials (thus not the user mail account). There are apps in the App Store using mailcore, so i would guess it's legit.
Yes there is a way using Swift-SMTP.
Send email
Create a Mail object and use your SMTP handle to send it. To set the sender and receiver of an email, use the User struct:
let drLight = Mail.User(name: "Dr. Light", email: "drlight#gmail.com")
let megaman = Mail.User(name: "Megaman", email: "megaman#gmail.com")
let mail = Mail(
from: drLight,
to: [megaman],
subject: "Humans and robots living together in harmony and equality.",
text: "That was my ultimate wish."
)
smtp.send(mail) { (error) in
if let error = error {
print(error)
}
}

iOS - Make sure an in app email goes through

If I have an app that sends emails or sms messages to a users friends from within the app how can I check to make sure the message has gone through and sent successfully, or wether or not bad service got in the way of the message successfully sending and what not or can this not be done?
To see the result of sending an email from your app you should implement the delegate method mailComposeController:didFinishWithResult:result:error
- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
{
if (result == MFMailComposeResultSent) {
// email was sent successfully
} else if (result == MFMailComposeResultFailed) {
// email failed to send
NSLog(#"mail send error: %#", [error localizedDescription]);
}
}
Be sure to set the the delegate of your MFMailComposeViewController to self.
Apple docs reference here
Of course this only tells you whether the email was successfully sent. There's really no way to know that the email gets delivered on the recipient's end.

Resources