Not receiving webhook photo with location action notifications from Kaizala - kaizala-action

I have subscribed to a Kaizala webhook with the following request.
{
"objectId":"XXXXXX",
"objectType":"Group",
"eventTypes":[
"ActionCreated",
"ActionResponse",
"SurveyCreated",
"JobCreated",
"SurveyResponse",
"JobResponse",
"TextMessageCreated",
"AttachmentCreated",
"Announcement",
"MemberAdded",
"MemberRemoved",
"GroupAdded",
"GroupRemoved"
],
"callBackUrl":"XXXXXXX"
}
I can receive the photo and location notifications, however, the notification for photo with location does not post.

Currently Webhook response is not sent for Photo with location event. But this is a great feedback. We will add this support soon. We will reach out once its implemented.

Related

Create Microsoft Graph Api Subscription for accept/reject meeting event by attendees

In my project, I have created Rest API project to create subscription and to listen notification from Microsoft Graph API.
I want subscription for following things:
When I create meeting room event then I want to get notification if any attendees accept/reject that meeting room event.
If whole meeting event is cancelled or moves to another time slot or added any new attendees.
I was expecting all above gets covered by following code but it is not :
var subscription = new Subscription
{
ChangeType = "updated,deleted",
NotificationUrl = $"{_notificationHost}/listen",
Resource = "me/events",
ClientState = Guid.NewGuid().ToString(),
IncludeResourceData = false,
// Subscription only lasts for one hour
ExpirationDateTime = DateTimeOffset.UtcNow.AddHours(1)
};
It does not send notification when accept or reject done by attendee with 'Do not send a response'. How I can get notification for this?
I managed both scenarios :
I am getting notification for attendees's reject/approve response on my listen api : NotificationUrl = $"{_notificationHost}/listen",
If new attendess added/removed or meeting time change or meeting cancelled then also we can get notification in Listen api.

Identifying users in Rails Web push notifications

I'm developing a Rails application, and I'd like to send web push notifications to specific users when certain actions happen, e.g:
A user started tracking a timer, but the timer has been running for more than 6 hours. Then the app sends that user a web notification.
I've been doing research and found this tutorial, the author implements push notifications for Rails, however there's no insight on how to identify the users.
From what I understood, the users needs to subscribe from their browser to be able to get push notifications, however, considering each user can use the application from multiple browsers, how can I automatically subscribe/unsubscribe a user for notifications in all browsers they use the app from?
So, what I did was adding a notification_subscription model to my User model.
On my javascript, I check if there's a current browser subscription present:
this.serviceWorkerReady()
.then((serviceWorkerRegistration) => {
serviceWorkerRegistration.pushManager.getSubscription()
.then((pushSubscription) => {
if (pushSubscription && _.includes(subscriptionEndpoints, pushSubscription.endpoint)) {
return;
}
this.subscribe();
});
});
I check if the current subscription is already present in the user stored endpoints, and subscribe if it isn't.
On subscription I send the new endpoint to the backend, which adds the new subscription to the user:
$.post(Routes.users_subscriptions_path({ format: 'json' }), {
subscription: subscription.toJSON()
});
Then I can send notifications to users to every endpoint:
def push_notifications_to_user(user)
message = {
title: "A message!",
tag: 'notification-tag'
}
user.notification_subscriptions.each do |subscription|
begin
Webpush.payload_send(
message: JSON.generate(message),
endpoint: endpoint,
p256dh: p256dh,
auth: auth,
api_key: public_key
)
rescue Webpush::InvalidSubscription => exception
subscription.destroy
end
end
end
The webpush gem raises an InvalidSubscription exception if the endpoint is invalid, we can destroy that endpoint to keep only the valid endpoints from the user.
The endpoint is unique by browser so you need an additional authentication scheme on the top of your app to send user's information along with the new endpoint.
You need to attach metadata (i.e. the user ID) to the endpoint when you store it on your server:
#subscription = Subscriptions.new endpoint: params[:endpoint]
#subscription.user = current_user
// or if you send with AJAX the user id together with the endpoint
#subscription.user = User.find params[:user_id]
In the second case I suggest to sign the user ID or use a secret token, otherwise anyone would be able to subscribe to push notifications as if it was another user.
Then you can delete from the database all the endpoints that belong to that user ID to unsubscribe all his devices.
However I don't think it's a good practice: a user may want to receive notifications on a device and not on another one.

Received webhook notification but with empty data in servicem8

I can successfully register the webhook in serviceM8. By list the webhook subscriptions i got the result like this
[{"object":"job","callback_url":"http://ABC.XYZ/oauth/webhook/m8","fields":["active","payment_processed","uuid","company_uuid"],"active":true}]
But when i try to create new job & approve the job in servicem8, i received the notification from serviceM8 but the data in body is all empty like :
body: { '{"object":"JOB","entry":': { '"payment_processed"': '' } }
Am i missing something in webhook setup ???
Webhook notifications will not include the data record itself, only a reference to the record that has been changed/updated.
Your callback url should be receiving a JSON body similar to the example here (under Handling Webhooks):
http://developer.servicem8.com/docs/platform-services/webhooks/
Once you receive the notification, you will need to request the updated record using the supplied resource_url.

Is there anyway to save push notifications?

When user a sends a push notification to user b, user b will receive the notification, but once they click on it the payload from that notification is gone. Instead when user b opens the notification, the payload in the notification will get saved to parse, so he can view all the notifications that were sent to him. It's like a notification history. Below is my code to send notifications. I need help on how to save the payload within those notifications, so users can look at notification history.
func pushNotifications(){
let userQuery: PFQuery = PFUser.query()!
userQuery.whereKey("objectId", containedIn: Array(setOfSelectedFriends))
let pushQuery: PFQuery = PFInstallation.query()!
pushQuery.whereKey("user", matchesQuery: userQuery)
let push = PFPush()
push.setQuery(pushQuery)
push.setMessage("\(username!) wants you to meet them at \(location!)")
push.sendPushInBackgroundWithBlock {
success, error in
if success {
print("The push succeeded.")
} else {
print("The push failed.")
}
}
}
You probably should do it the other way around, make a table where you save new "MeetingInvites" and whenever a new entry gets added send a push notification to the corresponding user.
Make the push notification a side effect of the actual new entry. Not make the entry a side effect of the push notification.
That would also save you the trouble of having to deal with notifications that get lost - maybe the receiving user opens the app, then something crashes and your push notification and all the connected data would be lost.
A little bit more detail: Create a column for the location, one column for the "requesting" user and one for the "partner". In your code, set the currentUser as the requesting one, and the partner as the ... well ... partner. Then either on your client device or on the server create a push message. In both cases send the push message to the "partner".

How to manage Online / Offline / Away status in background PUBNUB + IOS?

We want to implement Online/Offline using Pubnub framework in iOS but app doesn't work in background more than 10 minutes. We have tried to implement this by enable location feature and its working fine. But client does not want to enable location service for this purpose. So how we will manage to make run enable in background infinite ? (QUE 1)
And if we want to put Online/Offline/Away status in our code
Where we should show,
Online: When user open the app
Offline: When user close the app from background OR delete the app
Away: When user tap on home button and app is in background.
How we will implement this (Specially AWAY & Offline state)?(QUE 2)
Is there any other way to manage Online/Offline/Away ? (Without Pubnub ) (QUE 3)
If Yes, please describe the way.
How we will manage Online/Offline/Away using web service? When we call that web services? (QUE 4)
We are using almost 3-4 year old base code. So should we add any other parameter in plist to enable app in background for more time ? (QUE 5)
Please guide us.
With PubNub Presence, you have the best way to provide this feature in your app but due to the way iOS handles app going into background, you may or may not have opportunity to update this status (depends on how app is configured to run).
But very simply, by enabling Presence for your PubNub keys, when a client subscribes to a channel, a join event is sent to all other subscribers that are listening to presence on that channel.
When the app goes into background, if you have opportunity to do so, you can call unsubscribe on all the channels the client is subscribed to and a leave event will be sent to all the subscribers of that/those channels listening to presence events.
And if the app were to get killed or go to background where you do not have a chance to call unsubscribe, when the app is offline/disconnected for longer than the configured heartbeat period, then a timeout (equivalent to a leave event) will be sent to all subscribers listening to presence events.
The heartbeat defaults to 5 minutes but you can configure this to a lower setting like 60 seconds (or shorter for use cases that require this but never lower than 15 seconds).
If you would like your server to listen to Presence events, then you will want to use our Presence Webhooks (docs coming soon). Please see this StackOverflow thread about how to implement PubNub Presence Webhooks and how to get your PubNub keys configured to use them.
There are two scenarios:
User puts App in the background mode
User quits the App.
What you need to do is to get notified when these events occur:
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(appWillResignActive)
name:UIApplicationWillResignActiveNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(appWillTerminate)
name:UIApplicationWillTerminateNotification
object:nil];
Now, in that respective methods, set state using PubNub's API
-(void)appWillResignActive
{
// Sample dictionary
NSDictionary *dicState = #{ #"userName" : senderName, // Optional
#"status" : #"Away", // Or whatever
#"isTyping" : #FALSE // Optional
};
[AppDel.client setState: dicState
forUUID: senderId // current user's UUID
onChannel: KPubNubChannelName // channel name
withCompletion: ^(PNClientStateUpdateStatus *status)
{
NSLog(#"%#", status);
}];
}
Once state is updated on PubNub, all the subscribers of that channel will be notified i.e. follwing method will be called:
- (void)client:(PubNub *)client didReceivePresenceEvent:(PNPresenceEventResult *)event
{
if (![event.data.channel isEqualToString:event.data.subscription])
{
// Presence event has been received on channel group stored in event.data.subscription.
}
else
{
// Presence event has been received on channel stored in event.data.channel.
}
if (![event.data.presenceEvent isEqualToString:#"state-change"]) {
NSLog(#"%# \"%#'ed\"\nat: %# on %# (Occupancy: %#)", event.data.presence.uuid,
event.data.presenceEvent, event.data.presence.timetoken, event.data.channel,
event.data.presence.occupancy);
}
else {
NSLog(#"%# changed state at: %# on %# to: %#", event.data.presence.uuid,
event.data.presence.timetoken, event.data.channel, event.data.presence.state);
}
}
When it gets called, you will have to update your datasource accordingly which will reflect the state update.

Resources