React Native - IOS Platform — How to bring App in focus / foreground from background on receiving Push Notification - ios

I am using OneSignal to send Push Notifications to my React Native App. On receiving notification I bring up a Custom React Native screen to take some input from User.
I followed the instructions mentioned here:
https://documentation.onesignal.com/docs/react-native-sdk
https://documentation.onesignal.com/docs/react-native-sdk-setup
The above two guides mainly explains how to Initialize OneSignal, setup notification listeners and other required Native settings.
After the above configuration I am able to send Notification (and bring up the Custom Screen) to App on iPhone but only if App is in Foreground. The App was not receiving notification if in Background.
Then I followed the below article by Oleg Kalyta and configured:
https://hackernoon.com/complete-guide-receive-push-notifications-in-react-native-ios-app-38b1ec5b1b15
It explains how to configure PushNotificationIOS RN package and setup some more functions and listeners. Though I don’t quite understand why I need these functions if I have already configured OneSignal listeners. And how it will impact on my App’s performance with too many listeners.
After this configuration I am able to receive notification (it comes at top of iPhone and goes away after 2-3 seconds) even if the App is in Background. But it does not bring my App in Focus and does not show Custom screen.
I am looking for help to resolve the issue and show the Custom screen if App is in Background and it receives notification.
Interestingly the OneSignal listeners are getting called and I am also able to see the sent data in the logs but I am not sure how to bring up the IOS App in focus.
In Android I am able to even unlock the phone and bring the App in focus on receiving notification. I have written some Android Native code using Android PowerManager and WindowManager packages. I am calling this native code from my React Native OneSignal listener to Wake up the phone and bring the App in focus and display the custom screen.
The same thing I am trying to achieve in IOS.
Please can anyone help. I have gone through lot of articles on Net but I am not able to find any solution.

Related

OneSignal iOS Settings keeps disappearing

I'm currently working on implementing push notification for my app using React Native and OneSignal. I've managed to set the settings for Android and iOS, but I noticed the iOS side keeps disappearing from time to time and appearing again. Same thing with the dashboard, the iOS logo sometimes appear and disappear.
When trying to send notification while only targeting my iOS device, sometimes the system would show Total Number of Recipient to be 0 as well. The device itself only received the notifications from time to time while the android side always received them.
Anyone ever have this issue as well? And did you managed to solve it?
EDIT:
I cannot seem to find a way to fix this so I decided to do a workaround instead by creating another project inside OneSignal and disable the old one. The push notification is working fine now.
OneSignal fixed this issue today with the dashboard not saving/persisting data. You should be able to save your settings now. Best to contact OneSignal directly with issues like this.

Program an iOS app to launch itself at specific times

I'm developing a medical alert and record keeping app for iOS for a client. The app needs to be able to open itself at specific times based on a schedule that is set remotely.
I've searched around for how this can be done, and I keep running into other apps that let you schedule app launch times, but this needs to be a self contained solution.
I'd rather not JailBreak the iOS device to make it work, and I've come across articles that say iOS 9+ now has this capacity, but no instructions on how to make it come about.
Any clues, tutorials, or other information on how to accomplish this?
You can use "silent" push notifications (with "content-available") on iOS 7+ to launch the app when the push notification is received on the device. You will get a chance to process the notification, and the app will be launched if it's not already running.
However, it still won't work if the user has force killed the app.
Also, iOS will not launch your app if it feels you've gone over the daily processing time or data quota.

Text reply after watchOS notification is failing only when the corresponding app is installed on the watch

I have an iOS9 app with a watchKit 1.0 Extension. Most functionality is working fine. One of the main features of the app is a private messaging feature, which is also working great.
I'm using UIUserNotificationActionBehaviorTextInput for iOS9+ devices so that when a user receives a notification on their watch, they will be able to use the built in reply feature.
This works great, but only if the watchKit app is NOT installed on the watch. Users are able to reply to a notification on their watch with canned responses, or dictate a response with no problems. Note, this does NOT launch the watchKit app - it just uses the built-in reply functionality of the watch.
When the watchKit app IS installed on the watch, the "Message" and "Dismiss" buttons appear as expected. But as soon as someone clicks the Message button, instead of being able to tap or dictate a response, it just immediately goes back to the watch face.
It is 100% reproducible using two separate sets of an iPhone 6 running iOS9.1 and Apple Watch running watchOS 2.0.1. Since notifications can't be tested in the simulator, this is a very difficult problem to troubleshoot.
I could really use some guidance in what steps to take next.

Sinch notifications don't show up when app is not open

I am developing an ios app using Sinch with swift and notifications are showing when the app is working in background but when I close the app, notifications won't show up. All resources in Sinch docs are in Obj-c that's why I am asking this question in here. Is there anybody worked with Sinch using swift and can explain to me little bit.
Its actually not a swift thing at all, it applies to objective c as well :D
When you open the app and you have pushed a notification (or not) you will receive a regular on message recieved to you MessageClient delegate, when you get that and are not in the chat screen you need to decide what you want to do, either show in in app notification or take the user to that screen (I suggest showing an in app notification)

What's solution to make task background in iOS same service in Android?

I'm newbie iOS. I have been develop Phonegap for Android and iOS. My App is update data from server every 1hour. In Android, i use service to do that. My app in Android working very good. Now, i want to develop version for iOS, and i have problem when update data from server every 1hour. I was research but not find anyway for my app.I don't know what's solution to replace for service in Android. Can you help me, what's solution. This have been kill me. Thank you so much.
Short answer is NO as Apple has restriction on background task running especially cases like yours.
But if you are downloading small amount of content, you do have some other options. From IOS 4.0 or above, you can declare your app to run in background when you fall under the following categories:
Audio
Location updates
Voice over IP
Newsstand downloads
External accessory communication
Bluetooth networking
Bluetooth data sharing
Background fetch (IOS 7)
Remote notifications (IOS 7)
In order to do so, you need to flag your app in the info.plist for Required Background Modes option. Apple will review your app specific in this area once you declared the option.
For your case to download the data, the possible option is to use the new feature in IOS 7 that's the background fetch or remote notification above. The suggestion from DOM was not asking you to download the content through push notification. But instead to use push notification to wake up your application and start downloading new content.
If you don't want to use push notification, the only way to go is register for background fetch. However, no matter which option you want to use, each download will only last for 30 seconds. And after that, your app will put into suspension mode again.
you can have a look on the link here:
Declaring Your App’s Supported Background Tasks
I think your best bet would be to use the push services instead of having your app go get data. Making your app do it is unreliable with phonegap apps because you cant create a service interface and you can not guarantee that your app will be running. With push service though, if your app isn't running, it will be woken up in a manner of speaking.
Take a look at this great how-to article that also discusses what push provides you.

Resources