Distriqt push notification handle on start app from notification centre - air

I've just bought Distriqt ANE pack and can't get Push Notification worked for some case.
When application isn't started and I receive PN it shows in notification area, but when I try to open app from notification centre ( clicking by notification ) I can't get access to PN which opened application.
I've read documentation and asked Distriqt support but with no luck.
In docs we have:
Not running: A notification is displayed in the notification area.
When clicked the application is started. When you call register()
you'll immediately receive the notification event.
Support team answered:
You need to make sure you add the listener for notifications before
you call register. You should receive the notification immediately
when you call register if the application was started from the
notification center
My code:
PushNotifications.init( PN_DEV_KEY ); //it doesnt init for 2nd time!
if(PushNotifications.isSupported) {
PushNotifications.service.addEventListener( PushNotificationEvent.REGISTERING, onPnRegistering );
PushNotifications.service.addEventListener( PushNotificationEvent.REGISTER_SUCCESS, pnRegisterResult );
PushNotifications.service.addEventListener( PushNotificationEvent.UNREGISTERED, pn_unregisterSuccessHandler );
PushNotifications.service.addEventListener( PushNotificationEvent.NOTIFICATION, onPushNotification );
PushNotifications.service.addEventListener( PushNotificationEvent.FOREGROUND_NOTIFICATION, onForegroundNotificationReceived );
PushNotifications.service.addEventListener( PushNotificationEvent.ERROR, pn_errorHandler );
var registerResult:Boolean = PushNotifications.service.register(GCM_SENDER_ID);
But after register call no event has fired. It just do standard register routine and that's it.
Please help!

This feature was only added in one of the more recent releases. Always try to update your extensions before reporting a bug.
Thanks

Just updated to the latest version 2.6.iOS.2.1 from GitHub
and it works just fine.

Related

Expo/React Native : A Continuous Alarm or Sound Notification (like receiving a call ) triggered by remote server

I am using Expo to build an app that will pop up a notification with custom sound and vibration when triggered remotely. The alarm/vibration would play until its dismissed by the user or it times out (say after 1-2 mins) .
Example use case would be when a partner needs my immediate help with baby, they can press a button the app and that would send signal to backend server which would then trigger the notification with alarm on the app at the other end. When the notification is dismissed, an acknowledgement message is sent with Yes or No type message. If the notification times out, then another message is sent like "no response".
Key point to note is that when the app is fully closed, the notification should still be able to pop up.
From my limited understanding , expo notification or push notifications in general cannot achieve this as they don't allow us to create notifications that directly open the app. Even a solution which works like phone or video calling apps (which open when someone calls you ) could work.
Any help would be much appreciated.
Many Thanks!
I looked up expo push notifications but they are limited in terms of customising the notifications.

OnNotification() function dosen't work when i send localNotification

I am using react-native-push-notification to implement push notifications, I have followed the documentation properly when I send remote notification OnNotification() get called properly but when I send LocalNotification using PushNotification.LocalNotification() I get proper notification pop-up but it doesn't trigger OnNotification() function, I have gone through lot of stackoverflow questions and git issue still no solution, can anyone have solution have on this issue that would be great help
For ios this method will trigger/callback when you click on the notification and launch the app from killed state
PushNotificationIOS.getInitialNotification().then(notification => {
if (!notification) {
return;
}
});
I just implemented and tested in release mode, it worked well. For Andriod i'm still figuring it out which method triggers the call back in killed state.
Note: Above code works only in release mode for iOS.

Cannot register device with TalkJs for push notifications

I am working on a React Native app that uses TalkJS. We want users to get a push notification for every message they receive. The messages are going through but we aren't getting notifications. We have uploaded our .p12 to the TalkJS dashboard and followed the docs for setting up a React Native project. Below is the relevant code we're injecting to the TalkUI loadScript. We followed https://talkjs.com/docs/Features/Notifications/Mobile_Push_Notifications.html
const res = await window.talkSession.registerDevice({ platform: "ios", pushRegistrationId: "${deviceToken}"});
alert("registering deviceToken ${deviceToken} response: " + res)
We are getting the alert with the correct deviceToken but this method does not return anything. We tried .then and an error first callback but nothing is coming back from this method.
Edit: this method is not designed to return anything, so the response is expected to be empty.
The Promise was designed to not return anything as Kapobajza mentioned.
From their support chat: "We have an issue regarding push notifications on iOS when using React Native."
Edit: this issue has been resolved. In addition to work that needed to be done by the TalkJS team, push notifications require a user to have a 'role', as is very loosely implied in the Overview for Push Notifications

Listening for Expo push notification

I'm really confused on how notification listener works in expo, especially for a killed app, I read the doc and I knew that addNotificationResponseReceivedListener listener use when the app is ( in background or killed). I need to know how this listener work and when I unsubscribe the listener does it keep listening?
this callback is called after the user taps on the notification and the App open. you will receive an object with the push notification info (like title, message and extra data) and from there you can decide if you will redirect the user somewhere or just resume the app flow.
If the app is not subscribed (if you didn't generate the token for push notification) you will not receive the notifications.
If you just didn't create the callback responseListener.current = Notifications.addNotificationResponseReceivedListener(response => {..... your app will show the notifications anyway (normally you just use the callback when you want to do some action with the notification info)
Hope this info helps.

worklight what is the event fired when the application exit

Could you please help me to find the event or WL method fired when the worklight application exit ?
I have read the developer guide and may be i have miss it.
thanks.
regards,
jack
IBM Worklight ships with Apache Cordova, you can try to use Cordova's Event API. Specifically the pause event.
This is an event that fires when a Cordova application is put into the background.
//Add the event listener
function wlCommonInit() {
document.addEventListener("pause", onPause, false);
}
// Handle the pause event
function onPause() {
//...
}
When you quit the app, the app quits. Nothing else happens.
Otherwise, you'll need to edit your question and be clearer.
Do you mean:
when the app quits
how to programmatically quit the app
what happens when the app moves to the background
something else...?
Availability:
Android
Windows Phone 7.5
Windows Phone 8
Edit: based on the comment to this answer, you want to use WL.App.overrideBackButton, so that once tapping on the physical Back button instead of quitting the app you could display a WL.SimpleDialog or alert or whatever else you want to do. An 'OK' button could then trigger WL.App.close to quit the application (and a 'Cancel' button that will do nothing, to keep the user in the app).