How to create proper notifications on iOS (FCM doesn't seem to be the way)? - flutter

According to FCM official documentation:
On iOS, if the user swipes away the application from app Switcher, it
must be manually reopened again for background messages to start
working again
See:
https://firebase.flutter.dev/docs/messaging/usage/
However, any app with notifications that I can think of (Whatsapp, Facebook messenger, Tinder etc) will still notify the user if there's a new message, even if the app was swiped away. A different behavior will be a very bad UX (as a sidenote, background messages don't work on FCM ->APN -> client if the physical iPhone was restarted, see https://github.com/FirebaseExtended/flutterfire/issues/7785)
So FCM isn't the right way for iOS. I thought that APN might be the right way, but to my surprise, all of the APN packages seem to be dead (for example see https://pub.dev/packages/flutter_apns - was last pushed 6 months ago and authors stopped responding to issues).
Flutter is a popular framework which exists for years now, so there must be a way to implement notifications properly. What is that way?

Related

Flutter connection back online background event listener

I've been trying to learn Flutter by developing an Offline-first application using non-firebase backend API. The problem I am trying to solve derives from the following requirements:
Given User devise is Offline and he creates a record in the app, the record is stored on a local Database and is synced to backend once app is back online
If the app is not in the foreground, user should receive notifications once he is back online, given something changed on BE while he was offline.
Now, the problem is that reading through some packages that Flutter provides like background_fetch, I've stumbled upon the following limitation: "Background Fetch is a very simple plugin which will awaken an app in the background about every 15 minutes, providing a short period of background running-time."
The problem is that testing a similar IOS offline-first app I've noticed that notification comes through the moment internet is back online.
My question is the following: How can I achieve an immediate response/notification from my Flutter app once internet is back online, given that application is not working in the foreground. A fetch once every 15 minutes would work but is obviously is less than ideal, and given there are already apps on App Store/Play market that are notifying me immediately just keeps me awake at night. Is there a way to configure an event listener for connectivity change without relying on the 15 min limitation?

Content push for Newsstand in iOS 7.1 to change magazine cover suddenly not working in existing Newsstand App

We noticed that the silent content push messages that we are sending to update the magazine cover of our Newsstand App suddenly stopped working specifically in iOS 7.1.
I just did some testing sending the content push to the following devices:
iOS-5.1.1 -> push received -> magazine cover updated -> OK
iOS-7.0.6 -> push received -> magazine cover updated -> OK
iOS-7.1 -> push never received -> NOK
However, if I send a push alert message to these devices, all alert messages are correctly received and shown, so I am sure that I am using the correct device tokens.
And this issue is on an existing App live in the App store, never having this issue before and it seems to be specific to iOS 7.1.
This is the content push message we are sending:
$payload = '{
"aps" :
{
"content-available" : 1,
}
}';
Anybody else having the same problems specific in iOS 7.1?
Thx!
I am having that issue also on 7.1 in development. If connected to XCODE we see the method application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler invoked... ONCE we disconnect from Xcode... that method does NOT get called based on reviewing the console.
EDIT :: Today during testing against the sandbox environment with a iPhone on iOS7 7.1 (11D167) the content-available starting working ?? We are getting calls into didReceiveRemoteNotification fetchCompletionHandler: NOW, even when phone is NOT connected to XCode or anything. Even if the Phone is Locked and Application is in the background... which is what we needed and very important.
Really odd... but we did find that the Manual Do Not Disturb was ON.. on this test phone.. not sure how that got on and if that was issue. Make sure that is NOT ON.. otherwise you will not get any remoteNotification calls into your application. We may have gotten off track with the other postings that content-available was broken on ios7.1.
If anyone knows anything else about this, please share.
From https://support.magplus.com/entries/84992596-About-Lower-Issue-Download-Counts-Since-iOS-7:
About Lower Issue Download Counts Since iOS 7
With the release of iOS 7, Apple changed the way Newsstand Push Notifications work, and it is a significant departure from how Newsstand Push Notifications were delivered with iOS 5 and iOS 6. With iOS 7, Apple attempted to change the way these notifications worked, primarily optimizing the mechanism for apps that receive e-mail and Twitter updates and notifications multiple times within a 24-hour period. Part of the problem with iOS 7 is that it is not clearly differentiating Newsstand Push Notifications (which initiate a background download of content) from standard Push Notifications (which just deliver text).
A key change in iOS 7 is that if an app is killed manually by the end user, then the app simply does not receive Newsstand Push Notifications to automatically download new content in the background. Users manually kill an app by bringing up a screen of currently running apps and swiping one up to force it to quit. Apple views this scenario as one where the end user has made a conscious decision that they do not want the app running/performing background operations which consume battery life.
The two unique features of Newsstand Apps as promoted by Apple self in 2011, 2012 and 2013 (in WWDC video's about newsstand) were:
A - background download of new Magazines and
B - changing the cover when a new Magazine is available and showing a badge.
Unfortunately, in the real world situation, since iOS 7, Apple has killed both these features. Content push messages needed for these two features don't work if the user has killed the Newsstand App. Which in real world situation will almost always be the case.
Suppose you have a Magazine that appears monthly. How big is te chance that the user will have your Newsstand App running all the time in the background? I think almost none...
Before iOS 7, this user could be notified via a content push message resulting in a badge and a new cover visible in the Newsstand.
Since iOS7, these features are gone in real world situations.
Result: much lower magazine views and downloads.
Thanks Apple!

Event While deleting the app from iPhone [duplicate]

This question already has answers here:
How to catch application uninstalling on device and let server know about this (iOS/Android)
(2 answers)
Closed 9 years ago.
I wish to hit a web service, whenever a user deletes the app from his/her device. Its just to delete that user from Db. Can anybody here help me?? Thanks In Advance..
Generally speaking, what you are attempting is probably not advisable. Even if it were possible to know when a user has deleted the app, how would you handle the situation where the user then re-installed the application and launched it? You also do not know why the user has deleted the app (perhaps they only wish to do so temporarily to free up space on their device? Perhaps their device was stolen and they are re-installing into a new, or upgraded device?)
If you separate your concerns (client has/does not have mobile app, vs client has/does not have active account) you can manage all these scenarios in a much more robust way.
Using an in-app analytics package (like Google Analytics, Parse or Flurry to name just a few) will give you insight as to your user behavior, and perhaps based on this usage data you can trigger handlers. For example, if you see a user has not used your app in a certain period you can email them or send a push notification to remind them? Perhaps you could email them to notify them "You have not logged in in 60 days, if you do not use your account within the next 30 days it will be deleted. Click here to re-activate your account."
No, can't do. There is no defined notification when an application is deleted. If you must talk to a server, suspend inactive accounts after a predefined time limit.
One other thing you can try is check for the UIApplicationWillTerminateNotification notification. Save the state of your app on your servers when it's transitioning to the background and cross your fingers your user will not delete your app when it's not running. Because once your app closed, you don't have any control anymore. Thats the iOS behavior till iOS 6.
There is no way you could know whether the app is deleted from device or not because no delegate method fires when the app is deleted.
Hope it helps you.

Push notification seen when I background the app

I'm seeing something very strange, and I'm hoping someone here can help me. Anytime I close/background my iOS app, the last push notification sent to that app via UrbanAirship pops-up at the top of the screen.
I've setup push notifications for my iOS app using UrbanAirship, and its associated libraries. I'm using the latest library from UA (1.3.3), and I believe I've configured everything correctly. I've gone over the basic documentation multiple times, and I'm not doing anything out of the ordinary that I can tell.
In my AppDelegate, I'm not doing anything with the UA libraries in the functions applicationWillResignActive or applicationDidEnterBackground, so I'm not certain why backgrounding the app would trigger this notification to come up. The documentation doesn't state that anything needs to happen in those functions. In the function applicationWillTerminate, I am correctly calling [UAirship land], but this issue isn't popping up when the app is terminated.
More data: I'm not actually seeing a new notification in the Notification center on my phone. I'm just seeing the message pop-up again, as if it were new.
This issue is perplexing, and if anyone can offer some insight or assistance with it, I'd appreciate it.

How to use Push Notifications

Regarding push notifications. How do I get the provision from APNS to implement push notifications in to my application. Help me guys.
start from these series
http://www.raywenderlich.com/3443/apple-push-notification-services-tutorial-part-12
iOS developers love to imagine users of their awesome app using the app all day, every day. Unfortunately, the cold hard truth is that users will sometimes have to close the app and perform other activities. Laundry doesn’t fold itself, you know :]
Happily, push notifications allow developers to reach users and perform small tasks even when users aren’t actively using an app!
Push notifications have become more and more powerful since they were first introduced. In iOS 9, push notifications can:
Display a short text message
Play a notification sound
Set a badge number on the app’s icon
Provide actions the user can take without opening the app
Be silent, allowing the app to wake up in the background and perform a task
This push notifications tutorial will go over how push notifications work, and let you try out their features...
I followed the steps mentioned in raywenderlich tutorial. It's some what easy to send Push notifications to my iPhone app by using my system as the temporary server(ie, sending the message by running the PHP code from the Terminal window).
But, while going for production and dynamic messages for different users at different time, it's very tough for me to set the service in a server.
So, I go with third party server to send Push Notifications. - Parse.com
Tutorial for how to use that API.
Documentation about the installations of the application.
Here, we have a tag parse.com for questions about this process.