This is a general question about the design direction. I am working on a weather app right now, I have user accounts, weather data from web server. I am able to retrieve the weather to the app and post these data in Parse. What I really want is that if the temperature is out of a certain range, send a push notification back to the app. So my question is how can I receive this notification when the app is not running or running in the background? Any thoughts, directions, keywords would be appreciated. Thanks!
You need to use Parse Cloud Code, to send a push notification when the server is notified about the change. One way I can think of is to schedule a job (Look at you console - Core -> Jobs) that will run let's say every hour and will check the temperature and send a push if it meets one of your conditions.
Good Luck
Related
I am building a chat feature using firebase Realtime database where an integer variable stores a number (int online) which when a chat is opened by person A it adds 1 to the database and then if another person B comes online and opens the chat then it adds another 1. So, if the number is 2 I know that both are online and active in the chat app so no need to send push notification.
But the issue that I am facing now is that if a user closes the app without pressing the in-built back button of the chat app (which when pressed subtracts 1 and becomes 0 when both users are inactive), then the number in the database is not changed which causes error in the push notification logic as when Person A sends a message, the code assumes Person B is online. How could this be solved? Please someone help me understand how push notifications generally work?
First off all sending push notifications is completely FREE. The only costs are made by the the backend (cloud functions) that executes the code to send them.
Secondly. If your users are in the app no push notifications will be shown. Even if you would like to show some in your app you would need to handle the onMessageReceived to show something to the user while he is in the app.
That means there is no need for you to do the thing you try to do. Just send all messages as if no user is in the app. It would even cost you more to check for each user if he is online or not and send the messages only if he is offline than just to send them to everyone.
I would recommend to read the docs a little bit to get a deeper understanding of FCM and if you have any specific questions we can all help you with it :)
Since push notifications may not be delivered sometimes (you can lose a few of them), you can not run code after the iPhone is turned on to check if there is new information available from the server, and you can not run code if your iOS App is closed... What can you do if you want to be as more accurate as possible in for example a Chat App in iOS?
I mean, inform the user as faster as possible that he has new info available. Comparisons: WhatsApp is updated without any delay.
You can do background fetch if your App is in background. But if the App is closed and you miss a push, it's not going to be up to date until the next push arrives or user opens the App. The same with silent notifications. If the app is terminated by the user, you are not going to receive it. Is there any way to solve it? It must be because other Apps do it... If there is any "private and secret" API that they are using (I read about this answer when no one know how to do that)... Is there any way to apply to use it?
UPDATE:
I'm using push notifications. The goal is to fix when a push doesn't arrive. Example: User A send chat message to user B. User B doesn't have the App open. The system lose the push. User B is not going to receive the message until he open the App.
Push notifications seems to be your only way even if you do loose a few of them, which I don't know how you would since they are pushed to apples secure server... but what do I know. As long as the user turns on the push notifications you should be fine. They may be delayed due to apples way of handling them. Honestly push seems to be the future, having your app constantly every minute or two check for new messages is a huge battery water in conjunction with normal texting apps. Your app should provide the best live data but since apple restricts to push notifications when the app is off or not running just stick to push notifications and only push major events to the user. I believe you can set up a job scheduler using quartz or schedulator to setup your server to push notifications to your app.
Using Parse.com for one of my iOS apps, aready on the appStore, I recently experienced a large number of remote notifications sent to users, in a rather short time.
The number of notifications sent in such a short time cannot be due to the normal functionning of the app.
What could make such a thing happen?
I made an Export Data on the same day. Could that be the cause?
I also modified one record, on one of the tables, but that only explains one push notification.
I was also working on the app, preparing for a future version, but do not think I did anything to fire a great number of notifications, or any notification at all.
Thanks for any suggestion.
Export Data has nothing to do with push notifications - that is not the cause.
Look through all of your push notifications that you sent. You can see your push records by going to the 'Push' tab on the Parse.com dashboard. It will allow you to see who was send each of the pushes and when they were sent, along with the JSON payload.
I would recommend taking a hard look at your push notification code to ensure you do not have an accidental loop, as that sounds like the most likely culprit.
first of all pls sorry for my question, it may appear silly, but i'm in a very early stage of IOS and parse programming.
I manage to create my app in order to receive remote push notification from parse.
I would like to save in one array all push notifications sent from parse to the app.
If i well understood, i can achieve it only if the user tap on the notification, in that way user tap on iphone , "wake" it and so i can execute the code to save the push notification.
But in case user do not tap on it, the data is lost. Same if the push notification has an expiry time, and in that timeframe i have no internet connection.
Is there a way to retrieve, from app, all the sent notifications for the app ? like i was querying any table in dashboard/data browser ?
Many thanks in advance for your help
If my request is not clear, pls tell me
B. regards
Fabrizio
You can create a new Class on your Parse Database and when you create and send you push object, you also save it in background in the new table.
So, when you need to retrieve any push notification atributes you should have them all stored in your database.
I am trying to create a local notification with the following requirements:
The user sets the days of the week for the notification
The user selects the time of day for the notification
The message of the notification requires calling an API to get the content.
For example, the user wants to know what the traffic is like on their commute every weekday at 0800.
There are some great tutorials on creating Local Notifications (like this one Adding Local Notifications in Your iOS App - appcoda), but I would like to know if I can make an API call to populate the message of the notification.
So rather than having an annoying "Check out the traffic now" notification which can quickly direct the user to the relevant page in my app, I would like to have: "There is minor congestion on the {road}" or "The roads look clear right now"
Is this at all possible? Thanks.
EDIT: Post iOS7 release
So it seems we have;
Background Fetch - able to fetch the new content and keep the content up-to-date
Remote Notifications - able to download the content when the app receives the push notification
Neither of these work in my scenario. I need to make a call as close to the user's specified time as possible. With background fetch, it is no use if the last update was at 5am when the roads were probably clear. Remote notifications are not ideal either as I am not pushing a notification, I would be displaying a local notification.
Does anyone know of a clever workaround to achieve this solution?