Get latest messages from last known mail Id - Mailcore - ios

Is it possible to get messages based on the last known Email UID. I am able to fetch emails using "fetchMessagesByNumberOperation" method. But somehow i need to implement a way to fetch newest emails from the last known email id.
Let say i have fetched x latest emails. And after 5 minutes i
got three more emails. Now i want to fetch the latest emails from the
last saved UID.
Is it possible to do?

Is it possible to do?
Yes it is.
There is a method named fetchMessagesByUIDOperation for this.
Here is my code in Kotlin, you can achieve same with swift
imapSession().fetchMessagesByUIDOperation(folder, flags,
IndexSet.indexSetWithRange(Range(lastMessageUID, Range.RangeMax)))

Related

Is it possible to send changeMessage notification at wallet creation?

I have a website with Symfony for create IOS wallet and i want to know if is it possible to send a changeMessage notification to my users when they install wallet on their phones like : Welcome on your wallet !
Is it possible ?
For informations, my changeMessage notification work when i update my user wallet, i create notification parameter to send a notification message with 255 characters Max and my changeMessage call this parameter when pass is update.
Thanks in advance
Yes, it is possible but it takes a bit of work.
When a user first installs your pass, iOS will call the web service to register. Once registered it will immediately make a call to get the latest version of the pass.
If the pass returned is different to the pass originally installed then the change message will trigger.
Since this will happen just once at the time the pass is installed, you should achieve the same experience you describe in your question.

CloudKit: can't discover identities

Pretty new to CloudKit. Trying to get all the contacts who are using my app. According to the docs and the tutorials out there I'm calling this:
discoverAllIdentities(completionHandler:)
The issue is that only my user (the one who is logged in on the device where the app is running) is returned. So I did some digging and noticed that if I call this one:
discoverUserIdentity(withPhoneNumber:completionHandler:)
and I use phone number directly the user is returned.
So after more investigation, I figured that the reason I do not get those users is that in my Contacts those users do not have their iCloud email stored. So once I add the email, they are returned by discoverAllIdentities(completionHandler:). So it appears the default implementation of that method is tied to iCloud emails for the discovery instead of phone number.
Is it possible to use phone number for discoverAllIdentities(completionHandler:)? Since, I don't think that as you add a new contact you would record anything but just phone number, so you will be missing to discover all those users.
Any kind of help is highly appreciated.

Firebase Cloud Messaging - Send message to all users

I'm new using the Firebase Cloud Message. I built an IOS app to receive push notifications. The app works fine. I send messages from the Firebase console and they're displayed correctly.
Now I`m trying to build an web api to allow my customer to send the push messages (without accessing the firebase console). Studying the documentation here I realized that I've always to have a "to", meaning a group, topic or device id.
My question is: can I send a message to all devices (like I can do in the console)? I yes, how so?
Thanks in advance!
You can make use of topics. Given that all of your users are subscribed to a specific one. Just like what I mentioned here (removed some parts, just check them out if you want):
If you are looking for a payload parameter to specify that you intend the message for all your users, unfortunately, it doesn't exist.
Commonly, when sending notifications to multiple users, you can make use of the registration_ids parameter instead of to. However, it only has a maximum of 1000 registration tokens allowed. If you intend to use this, you can make batch requests of 1000 registration tokens each, iterating over all the registration tokens you've stored in your app server.
However, do keep in mind that Diagnostics for messages sent to Topics are not supported.
I found this:
!('TopicA' in topics)
With this expression, any app instances that are not subscribed to
TopicA, including app instances that are not subscribed to any topic,
receive the message.
So you could probably use
condition="!('nonExistingTopic' in topics)"

How to send sms/email on scheduled time in iOS

I want to build an app in swift to send sms or email on scheduled date and time and the data need to be stored in database. I know we need to use MFMessageComposeViewController or MFMailComposeViewController for sending sms/email but how to send only on scheduled date?
For example: I want to schedule a sms for birthday wish of my friend on his birth date and let the app send the message on that specific date or time.
Can somebody share any tutorials related to this type of questions?
It sounds like you're trying to send emails and texts without prompting the user to fill in their content. The classes you mentioned are used to present views that allow the user to fill in the message content, like shown below.
If you would like to send email from the app without using the users email address and allowing them to fill in the content, you'll need to use an email service that provides an API, like Mailgun.
Unfortunately, you won't be able to send emails when the app is in the background. To do this, you should use a backend server to schedule emails.

Working With CoreData

I want to store only 20 Notifications which include
"Title,Detail and Received Time" fields inside Notifications Table.But,I only found solution for working CoreData with CRUD some example.But,I am still seeking for working with limitation when user fetch new results from api inside device database.That is where I am stuck.I don't know how to do it using CoreData because I was beginner at that.
Requirement :
1.Application can only store 20 Records maximum.So,when it reach max length,it will do First-In-Last-Out to Notifications table base on Notifications Received Time.(First Problem)
2.Every time the user do pull to refresh,my app fetch new notification from Web-Backend and replace or overwrite on user device database when it successfully download new notifications like "Push Notification Service App" on App Store.(Second Problem)
I really need a hand to pick up with core data flow which I am stucking at things I am not familiar with.
Any help or guide please?(Posting Sample with .json is appreciated)
use NSUserDefaults for that if your data size is small
Consider using a service, like RestKit or similar, to support your web service interaction. Each record should have a unique identifier supplied by the server so you can find an existing copy and update it instead of needing to delete everything and recreated it.
To trim your data use a fetch request with a fetchOffset and a sortDescriptors by date. This allows you to skip the newest 20 items and gives you a list of everything that needs to be deleted. If you're using RestKit you can supply this fetch request in a fetch request block and the deletion will be done for you.

Resources