iPhone Push notifications via mobile safari - iphone

Is there a way to simulate push notifications by pushing data to mobile safari? Here are 2 scenarios.
I make a web app via phonegap and dont want to use APNS but rather make a web-socket connection and push data to the device myself. On the device end is there a "alert" function I can call to emulate a pop up when a user is not in the application?
Lets throw web app out the window. Is there a way I can do this in native mobile safari? Im not talking about a plain old JS alert window that would only come up if the user was in the app, but be able to do so with it backgrounded.

You cannot run background tasks with mobile safari so for #2 you can't do true push notifications or alerts. However you can send a user an SMS if you have the user's phone number. This can have a hyperlink to a part of your web site (which can contain some sort of payload). You can use a service such as Twilio to help you send SMS'es. However this costs money. APNS does not.
For scenario #1 I'm assuming you're talking about a native app using a phonegap solution. In this case when the app is backgrounded you cannot access any UI at all and wake up the app and show a UIAlert. In fact unless an app is registered for location updates or background music, the app is effectively not going to respond after a set period of time (it only can "finish" certain operations it had started before). So the websocket solution will only be effective if the user has the app opened.
You could register a local notification that runs at some predetermined time which will show an alert. But that is not being pushed from the server so its probably not what you want.
APNS is your best solution for scenario #1. Its not that hard to implement and its pretty inexpensive. Check out urban airship if you want to avoid building out your own server-side components for it.

Related

Flutter best way to store App Notifications?

Is there a way to store app notifications in a flutter app. Most of the time this app will be closed and the app notifications will not directly be hitting the app. I would like to store app notifications in a notifications received section. I know I can get the notifications if the app is opened, but for if the app is closed and it just shows as a status, I can't get them in the device unless the user clicks on the notification message. and it opens the app. What options do I have and is what I am wanting to do even possible?
First interpretation of your question: If I read your question correctly, you're saying its not possible to have text in your notifications when the app is not open. This is definitely possible, almost all your apps create notifications on the device with more than just 'status'.
Another interpretation of your question: In response to a firebase cloud messaging message, you might want to save data or do some other background task, instead of just creating a notification the user sees. This is not enabled by default. There's lots more instructions on enabling and using this in the README
By default background messaging is not enabled. To handle messages in the background:
The golden nugget of information is _firebaseMessaging.configure(onBackgroundMessage: yourBackgroundMessageHandler) which is not listed under the receiving messages section.
Let me know if I misread. What do you mean by status?
You can use background Fetch to make the app stay in the background. The package will awaken an app in the background about every 15 minutes.

Swift: Detect and Cancel Another App's Notification

On Android, I have a NotificationListenerService that I can use in my third party app to intercept push notifications from a service's official app, cancel it, and post my own from my app's service (basically shadowing a push notification and making my own so I don't have to constantly poll the service's API).
Is there anything similar on iOS? I have been searching and cannot find documentation of anything that lets me capture another app's posted notification events, but I know it is possible to view their content as some apps (like the Samsung Watch's app) can forward notifications to other displays.
No there is no such feature on iOS. Apple goes to great lengths to prevent 3rd party apps from altering the behavior of the system or of other apps.

Local or Push notification

I have a simple application that shows some videos from a YouTube channel. I need to send a notification to my users when that YouTube channel have a new video.
I've been thinking and I realize that if I use local notifications the app will have to run a method every "5 minutes" and check if there's a new video, BUT when the user closes the app my method will stop running and the app will stop checking for new videos.
Otherwise, I'll use remote notification. I'll store the user device token into a database and check for new videos with PHP. When it happens, I'll send a push to all my users. Unfortunately, this case will overload the server that the PHP is.
My question is: What's the best solution? Is there any way to I keep executing a method when my app is closed?
Push is your best option. There isn't a good enough way to keep checking in the background to use local notifications accurately enough. Monitor for new videos on your server as often as you feel necessary and fire a push notification to the user. That model exists in many apps across the app store. Good luck.

Can an iphone application recieve push notifications from a custom server?

This is a very basic question on push notifications.
I need to know whether an iPhone application can receive push notifications.
I want them to operate as follows.
User installs the application.
When the application is not running, the user notices that something has changed with the application.
This is indicated by the application icon changing.
User opens the application and a new screen comes up that says:
"You have 3 new items to download"
The application will need to communicate with a custom server to obtain changes. The changes will only be known by that server, not the Apple App Store.
Is the above possible to program?
Yes. Your custom server sends them to Apple for distribution to devices. Read Apple's Push Notifications documentation for more info.

Automatically Restart WebApp after a phone call on an iPhone

I have an iPhone WebApp that is installed to the home page. When a phone call comes in or an email is sent it brings up either the phone screen or the email screen. After the user finishes the phone call or email, is it possible to automatically bring up the same web application that was previously open?
No. Also native apps can't do this consistently (only for incoming, but not for outgoing calls the app will be launched again; e-mail can be sent from within the app).
Kevin, yes it can be done with some effort. What you want is HTML5 local storage and perhaps HTML5 application caching as well.
What you do is not unlike what a pre-multitasking iPhone native app would do: you store the application state in the local storage and use it on launch to restore state. I don't believe you have hooks on termination so you'll have to store the state at every state transition, as it happens.