IBM MobileFirst Push Notification in IPhone - when the app is closed, pushNotificationReceived method is not triggering for the received notification - iphone

I am developing an application for IPhone, where I have to store all the notifications coming to the app using JSON Store.
In IBM Mobilefirst Push Notifications API, pushNotificationReceived is triggered when any notification is received in the app. So using this method, I can able to store the notifications in JSON Store.
When the app is closed [Not running in the background], the notification is successfully sent to the device.
But when I open the application by clicking the received notification, pushNotificationReceived method is triggering only for the notifications received when the app is closed.
Is this the default behavior of IBM MobileFirst?
If so, is there any work around to solve this issue.
I have seen that there are native API's available for handling the received notifications. Is that the only way to solve this?
Or Is there any native listener available only for receiving the notifications when the app is closed?

If tapping the notification in the Notification Center, the pushNotificationReceived should be called.
If tapping the app icon after a notification was received, the pushNotificationReceived API will not be called.
This is the expected behavior in iOS.
If (1) is not working for you as well, I suggest that you will test the sample Hybrid app to see whether it works for fails for you there as well - it should work: https://mobilefirstplatform.ibmcloud.com/tutorials/en/foundation/7.1/notifications/push-notifications-overview/push-notifications-in-hybrid-applications/event-source-notifications-in-hybrid-applications/

Related

Notifications lost after app is idle for longer duration - one signal sdk in flutter

I have implemented one signal sdk to receive notifications. I receive notifications when the app is in background. As the app is removed from the background I receive notifications for sometime but after that I do not notifications. As the app is idle for long time (overnight) app is unable to receive notifications from one signal dashboard. As soon as I open the app and put in background/ remove it from background I start receiving the notifications. Can anyone help me here? I tried putting the app Data saving mode but that did not help. I have the app process running in the background tasks when I am not able to receive the notifications.

An alert like whatsapp when app is in background in ionic

I am using One Signal push notifications in my ionic app. I want to show an alert when i receive a notification when my app is in background.
I tried using the platform pause and remuse functionality to check for background and foreground and then generate an alert when app was in background using ionic alert controller but was not able to produce the desired result.
I want a pop up dialog box like one in whastapp when u receive a message.
Can anyone please suggest a solution to this.
There is no way to achieve what you're trying to achieve through the use of OneSignal alone. The OneSignal plugin for Ionic has two calls to action:
handleNotificationReceived() & handleNotificationOpened()
The first one is called when the notification is received and the app is in the foreground.
And the second is called when the app is launched from the notification.
You would need some other service to record when notifications are sent to see if there were any when the app was launched by itself. If you use OneSignal's REST API to send notifications yourself, you can record when a notification is sent, and then when the app is launched by itself, you can fetch missed notifications or notification count from your own server. That's just one way you can do it.
But OneSignal is a push notification service, which send notifications. Even if you did FCM yourself and went through the scenario you mentioned, the results would be the same.
It's not a OneSignal issue. It's the way notifications are designed.

OneSignal - Sending silent notifications that only increment badge (app in background)

My app (iOS) is in background and I want to send a push notification that won't display anything (silent) and that will only increment badge count on the app's icon.
I am still not clear on how to manage that.
Is it a parameter in the message body or in my handler code?
Thanks
Try to send a push notification with content-available=1
Turn on the content-available (iOS) or silent-notification (Android)
fields. This will cause your application to be automatically woken
up in the background whenever a notification is received (even if
it's not clicked). Your custom code must be write with native code,
Java on Android and Swift or Objective-C on iOS. See Apple's
content-available for iOS and our Android Background Data guides for
details on receiving and processing the event.
In your app, we
provide an API that you can use to run custom code when the above
occurs. Your custom code can then save a copy of the notification
content on the device in order to be displayed in an activity feed
when the app is next launched. Or it could save a copy of it on your
servers.
https://documentation.onesignal.com/v3.0/reference

will push notifications work if user has neither allowed nor "not allowed" push notifications for my app yet?

I am currently updating my App, and I am planning on including Push notifications.
The main purpose for my push notification is to let users know that the app has been updated and they should check out the new features. Now with iOS7 automatically updating apps, users are less likely to open apps after they have been updated, let alone KNOW it has been updated. As a lot of users will just clear their notification centre's with out paying any attention.
So my question is...if a user has not launched my app yet to see the alert "[myApp] would like to send you Push Notifications" - Don't Allow / OK.
Will they see my push notification before they have had chance to allow or not allow?
Do push notifications work until "not allowed" has been pressed? Or do they not work until OK has been pressed???
Thanks for your help.
If they never launched your app, your app never registered to Apple Push Notifications on their device, so you can't send them push notifications.
In addition, your server is not likely to have the device token for a device in which your app was never launched (since it's the app's job to send the device token to your server).
And if you push a notification to a device token of a device on which your app never registered to push notifications, the notification won't be delivered (even if the app is installed on the device), and that device token will eventually be returned to you in the feedback service.

How to bring iphone app from background to foreground without user interaction when push notification comes in objective c? [duplicate]

This question already has answers here:
Relaunch iOS app without user interface when application in background?
(4 answers)
Closed 10 years ago.
Please suggest me objective c code for bringing the app from background to foreground without any user interaction when push notification comes.
Unfortunately it is not possible as Notification come and your app started automatically even without user interaction.
As Push Notification comes it Handles by OS.
If a notification for an application arrives when that application is not running, the device alerts the user that the application has data waiting for it.
Then It means user have to interact with the Device.
From The Apple Doc.
When the operating system delivers push notification (iOS or OS X) and the target application is not running in the foreground, it presents the notification (alert, icon badge number, sound). If there is a notification alert and the user taps or clicks the action button (or moves the action slider), the application launches and calls a method to pass in the local-notification object or remote-notification payload. If the application is running in the foreground when the notification is delivered, the application delegate receives a local or push notification.
That's All.
I hope it clears to you.
I dont think its possible. Once push notification came, the os itself handles and show notification if it is enabled for your app. Then from the notification, if you are going to app, then didReceiveRemotenotification callback will be fired.
Thanks.
It's possible but it would require a jailbroken iPhone and hook the push notification receiver to launch your app when the notification is received.
If you aim for App Store you can't.