Gmail Mailbox updates - ruby-on-rails

I have created a app in Ruby on Rails in that I want to get the all updates of the gmail mailbox, I tried with push notification provided by gmail in this link https://developers.google.com/gmail/api/guides/push but in this we get only those message related to that topic, but if i want notification on my server for all the messages then what approach should i adopt,
Please let me know if any one have any idea about it.

The topic is a separate issue from what labelIds to get changes for. The reference for watch() says that if you don't specify any labelIds in the watch, then you will get all the changes to the mailbox.

Related

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)"

Push notifications that let you watch for changes to Gmail mailboxes

I want to receive email from gmail, if new email comes, my server should get a callback and should get that messages.I tried with gmail push notification ,it says to create a topic , and subscription ,but my problem is ,How to restrict that coming email to be specific to that topic,or I am be wrong, I just want that email to come at my site , I am using ruby-rails
I'm not a Ruby on rail expert, however, this could be a potential solution to your question via Labels filtering actions. This can be achieved via the Users.watch method.
Here is an example provided by a fellow SO of how it can be done here.
Hope this helps or at least provides you a sense of direction. Cheers!

iOS - Can application send and receive messages to/from server?

I'm working on an iOS project. For this project I need an authentication system. However, if it's possible I don't want to use already built two-factor authentication systems such as Plivo or Sinch. I want to implement this feature of our application.
For this purpose, I need three things:
My application should get the phone number of the user and send it to server.
Server should send a sms to the number of user and my application should be able to read this message to get authentication code sent by server.
Application should be able to remove messages of this procedure from inbox and outbox of the iPhone used by user.
Now, i'm asking that can I implement this feature? I know this is a weird question but i've searched the Internet all day and could not get a certain answer. Thus I'll appreciate if someone informs me shortly.
Yes, you can that.
Your app can't read SMS messages received through the Messages app. The user would need read the message and note the code. Then switch back to your app where they could then type in the received code.
Your app can't access or modify any SMS messages received through the Messages app. The user would need to delete the message if they wanted to.

Rails, check if email was sent or not

I have an app that sends email to registred users. This app sends an automatic email to the user while he is using some functions. Plus, on the admin screen, the admin can send emails to all persons that didn't get the email sent automatically for any reason. I store in database a value showing if the email was delivered or not, so the admin won't send emails to someone that already got one.
The problem is: how can I check if the email was delivered correctly in order to update this value? I am not talking about tests, I need to check right after the method deliver is called if the email was sent, or if any problem happened, like connection loss or email is invalid. Is there any method or way to do this?
Thanks.
When you send a message and no error is raised, you can assume that the mail was delivered (at least you can assume that some system accepted the responsibility to deliver your message).
Nevertheless, there are many reasons for delivery failure; sometimes you may get an error hours or even days later. You will need to have a bouncing mail address and inspect returned messages. If you want to process bouncing, inspect an open source software with bouncing treatment such as phplist. This is no so trivial as you might think.
Another alternative is send e-mails through a dedicated service such us SendGrid. This services provide APIs that will allow you to retrieve information about your messages.
You can also use the mailman gem to parse reply email messages for bad email.

How to test whether a mail was sent successfully using ActionMailer?

I'm using ActionMailer in Rails 3 to send periodic emails. I need to know whether an email was sent correctly (as far as it is possible to do so).
#lists.each do |list|
email = Reminder.deadline_reminder(list)
email.deliver
end
Is there a property of the email object (class Mail::message from the Mail library) that will tell me whether the send went correctly (no connection issues, authentication problems, etc)? I've looked through the classes on Github but haven't been able to figure anything out.
It all depends on what you consider successful.
You can test to see whether your code sent the message. You can often check the log to see if the mail-forwarding host received it and moved it on toward its destination.
But, only proprietary mail systems support delivery-receipts. SMTP doesn't and probably never will because of privacy issues and the inability of the mail-client vendors to agree on how to do it. So, even if it is delivered all the way to the intended destination there's no way to know if the person read it.
Your best bet is to put a link in the message that the user clicks which will tickle an app on the server with a token that was unique for that message. When the app sees the token it sets a flag letting you know they got the message AND at least read the part about clicking the link. Then, if there has to be a response within a given time you also track when the message was sent and escalate if the token wasn't received back within the time-limit.

Resources