I'm using Delphi 10.4.2 to make an app for Android. I need a routine to run when a push notification arrives, but without the user needing to touch the push.
I've already found some examples here, but all of them are in Java, but it didn't solve my issue because Delphi is very different.
I was able to do this but only when the app is in the foreground. I believe the solution is to use a service to do this, but I couldn't get the service to read the push load. I also tried using a broadcast receiver, but it seems that nothing can interact with the push when in the background.
Does anyone have an idea how to do this?
Related
Recently Apple changed its way of handling VoIP notifications. Now they force you to use CallKit in the same run loop in order not to throw your notification away. The trace I get is this one
Apps receving VoIP pushes must post an incoming call (via CallKit or IncomingCallNotifications) in the same run loop as pushRegistry:didReceiveIncomingPushWithPayload:forType:[withCompletionHandler:] without delay.
When you get this warning three times, the system is "dropping your notifications on the floor".
The problem here is that I'm developing a hybrid VoIP app using the phonegap-plugin-push, and I'm afraid that the on notification event is not fast enough (or at least not the same run loop) for iOS.
Did anyone face this issue?
I've thought of changing to regular push notifications, but I can't find a way to make my app relaunch when it's killed and execute some code (launch CallKit, for example).
Edit:
I'm trying this approach with push notifications and I already configured the background modes. I noticed that sending the "content-available" and some data, like "badge", or "alert" in the notification, the app is launched if it went to background recently. After 15 minutes in the background the push notification arrives but the app doesn't launch anymore
Thank you in advance.
Our app uses CallKit and push notifications, and it launches when a push notification arrives for a new incoming call. It has to be configured in the project build and run once to register with iOS for this, though.
I found a solution:
Since iOS changed its policy about handling voip push notifications, it forces you to report a new incoming call when receiving the voip: https://forums.developer.apple.com/thread/117939
This plugin does it: https://github.com/mattkhaw/cordova-plugin-callkit
It merges two plugins (WebsiteBeaver/CordovaCall and Hitman666/cordova-ios-voip-push). It worked for me. I just had to remove the receiveCall from the javascript and tweak a little bit the plugin.
The methods related to the voip notifications register are in the cordovaCall class, so it is pretty straightforward to work with.
I'm looking into wrapping a PWA for IOS using ManifoldJS primary to get remote push notifications. However I don't see any documentation on how to address this in a generic way. I was hoping for some plugin that would display the push notification, potentially bring the app up if clicked on, and transmit events/payload into the service worker or main thread (perhaps through postMessage). Do you have to write native code to handle even basic push notifications? How have you addressed this?
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.
I face the following weird problem. I have a setup for notifications using Azure NotificationHub and Xamarin to develop an iOS app. It works fine with the following exception. Some times some notifications sent from my backend server (C# Visual Studio Windows Form Application) cause the iPhone to flash, I hear the notification sound, no notification is shown and older notifications of my app are removed from the list. Any idea what might be causing this?
Thanks
I see that you write:
I hear the notification sound, no notification is shown and older notifications of my app are removed from the list.
If you hear the notification sound, that means that the neither the APNS nor the Azure Notification Hub is the problem, because you are actually receiving the notification on the device.
No notification is shown.
1.This means that either the implementation of your code is deciding to actually receive the notification and do nothing with it. Check t Receiving Push Notifications while in background
This could also mean that in settings you disabled all the notification balloons, alerts and other properties. Make sure your app has actually the proper settings to work with notifications. (Believe me, it happens) https://support.apple.com/en-us/HT201925
Older notifications of my app are removed from the list. First of all I do not understand how do you have notifications on the list (did you actually received notifications somehow?). In any case, the notifications are removed by code when you enter your app. Please review this question (iOS application: how to clear notifications?)
Please mark my answer correct if it helped you, if not. Please provide more code of your implementation so we can provide you a better answer.
Best Regards.
When something happens on the backend, I want to let my users' iPhone app know of this change. (The app is currently open, not in the background...if that makes it any easier).
Should I install Firebase just to achieve this? What are other ways?
Push notifications is just the UI for the user...am I right?
You could use Apple Push Notification Service. If a Push Notification arrives while your app is in the foreground, it gets passed to you directly, rather than triggering a UI event. Last I knew, you can only have 1 notification outstanding at a time, so you should not depend on it for passing content, but just use it as as signal to query your server. With iOS 8 you can use background notifications, that do not require any user permissions.
Best way is to use Push Notification. Because it will save battery power on the device.
You can use the Apple Push Notification Service (APNS) to send push notifications to the user.
You could ask your server frequently about changes or use a blocking function in seperate Thread to handle events.
What kind of events are we talking about?
As Black Frog said, PNS is the easiest and most battery saving idea.