How should I send push notifications only to active devices? - ruby-on-rails

I have an iOS app with a Rails backend (and frontend). I am using Parse for push notifications.
I am trying to figure out the best way to only send push notifications that will be received; that is, I want to avoid sending them to:
Users who only use the web app and don't have the iOS app
Users who had the iOS app but then uninstalled it
The way that the Parse Push API works is that I can broadcast a notification on a certain channel, and any device that is listening to that channel will receive the notifications. Therefore, I am planning to make separate channels for each user.
Obviously, I am going to need to store some sort of information on the server side about who is running the iOS app. I'm curious as to whether anyone out there has experience solving a problem like this and can offer any wisdom. Thanks!

Parse already stores information about who is running iOS and Android apps. Check out the Data Browser, there is an Installation table with a deviceType field.
Have the iOS app register a unique (per-user) channel. If you're only sending push notifications on user channels, it will only be sent to users who have installed the iOS app.
There's not much you can do for users who had the iOS app but uninstalled it. Apple doesn't provide a way for applications to run any code before being uninstalled, so you can't unregister the device with Parse. I'm not sure if Parse does this, but Urban Airship polls the APNS servers and removes devices that have had the app uninstalled after a certain amount of days.

Related

Can I read others push notifications on iOS?

The main tread here, but is from 6 years ago (How can I read push notification from other apps?)
I'm making an app and I was thinking if is possible to read all of the push notification the device and get their data. (push notifications of others apps)
I know it is possible on Android. Is there any update for iOS?
TL;DR. No
APNs delivers remote notifications based on a token, generated by an app. The token at each moment of time is unique to the app instance, installed at the specific device. Only the app instance associated with the token is delivered with corresponding remote notifications.

Sending Notification to two different apps on same device using FCM for iOS

2 different apps installed in same device with same firebase project and in firebase separate app is created for each app under same firebase project.Will the Fcm notification work on both apps?
Before spending my time on Development I have searched a lot on it, many Developer reported the latest installed app on that device is only getting notification. IS it true.If so any Solution for it?
As long as both of the applications have retrieved a registration token and sent that to your application server and your server will send a message for both tokens, they will receive the message.

Send push Notification to Multiple Apps

I wanted to know if it is possible to send a Push to App A and App B at the same time, and if the user has both apps installed, only one will be shown.
Edit:
I was trying to prevent duplicate Notifications to be shown if the user has both Apps installed. But it seems this is not possible to do on the App side. We will have to come up with something server side to prevent duplicate messages to be sent.
Each app has its own deviceToken on that device. To send pushes to both apps you would need to send the push to both device tokens. The device will display both notifications.

APN push notifications for chat

I'm trying to add notifications to a private chat app that uses Firebase, unfortunately Firebase has an APN service but it must be configured and needs also a server app to manage it. I'd like to have the user notified when someone is texting him while the app is in the background. The problem is that APN (Apple Push Notifications) requires a server with a certificate and that is ok with me, but I'm looking for a way to send push notifications from an iOS device to another device, I mean device-to-device push notifications and the server has just to relay the messages as they are. In my case the APN server should only relay the messages that it receives from a source device to the destination device. I couldn't find a way to obtain that without writing sever code. I want to use pre-built existing services. Has anybody any idea on how to send push notifications from one device to another without configuring and writing server apps? I tried a workaround using the background fetch iOS feature, but the system si randomly giving my app execution time... and that means that my app could wait hours before being started by the system... so that is not a viable solution. Please help
Ok, probably what I found out could be helpful for others. Actually
what I'm looking for can be directly integrated in the app. You need a library like NWPusher (free on GitHub) which can be imported, and with just a few lines of code and the APN device token you get from the system, it is possibile to implement APN notifications... easily, but most importantly... for free.
UPDATE
Check also APNS framework on GitHub. It's written in Swift 3.0 and it supports the latest features.
You are essentially looking for a messaging / chat API to handle device-to-device communication. You might want to try Pusher or PubNub

Fetching data from server & adding notifications

I am working on an app which fetches student info from a server, like absences and events and grades. I have no access to the server, I only have the API.
I am asked to implement push notifications in the app, such that if a teacher marks a student absent, that student get a notification about that. I searched and found several approaches:
1- Background fetch: I tried using background fetch to check if the student logged in to the app was marked absent today, if yes, show a local notification. It worked when I simulated w background fetch, but never worked on the physical device.
2- I searched for using Apple Push Notification Service, and they all wanted me to build a server, and I dont know how to start. Can I build a server which pushes notifications to devices in a way facebook does it? That is, one user triggers a notification at another user, in other words: I dont want to use broadcast notifications.
3- Using third party, like backendless, firebase or any alternatives. Would that be a useful approach?
With Backendless your app (on the student side) can register itself to receive push notifications. This is done with an API call that registers the device on the servers provided by Backendless. Then you would build an additional application (could be a browser web app or a mobile app) for the teachers. The system allows to send targeted notifications, so when a student is marked as absent, you could use the API to deliver a push notification specifically to the student's device. Would be happy to discuss in detail, you can post your question to the Backendless support forum.
For my app I have designed Push service using Java APNS library.
Or You could use Microsoft Azure Mobile services to push a notifications to devices.

Resources