Using Ionic and OneSignal.
I am developing a messaging service in my app which sends push notifications when a new message is received. Ok so far.
But, I would like to merge notifications if they exceed a certain number, to avoid spamming the user with to much notifications.
Let's say if someone answer to one of my message with 3 different messages and that my app is in background, I would like the following to happen:
receive 1 notification
receive 1 other distinct notification
display only one notification which merge the previous two + a new one
Someone know, if possible and how?
I have just implemented something similar. You can look at the following documentation link
stacked notification
I just set the android_group parameter in all of my one signal api call and send a string key on every notification message.
{
app_id = "xxxxxxxxxxxx"; // one signal app id
headings = "One Signal Title Test";
content = "The demo test message";
android_group = "demo-application";
included_segments = "Active Users"; // to send notification to all active users
}
use postman to test
There's couple of parameters that you can set to group messages.
on Android you can use android_group witch accept a string and based on docs:
Notifications with the same group will be stacked together using Android's Notification Grouping feature.
And on iOS you can use thread_id witch also accept a string:
This parameter is supported in iOS 12 and above. It allows you to group related notifications together. If two notifications have the same thread-id, they will both be added to the same group.
There are couple more parameters that might be useful that you can check on Grouping & Collapsing OneSignal Docs
Related
In my Meteor app I have a mongo collection Notifications for user notifications, and I want to keep one document for one notification, even in case of multiple recipients. In each notification I have an array with users IDs. And I need to keep tack of read status for each user.
I tried to use an additional array to record who've read the notification like this:
{
...notification,
users: [id1,id2,id3],
read: [id2]
}
But two arrays cannot be indexed properly as I understand the docs. So my current approach is to have separate collection of UnreadNotifications with the documents referencing actual notifications by IDs and linking them to the users like this:
{
notificationID: notificationid1,
userID: id2
}
When the new notification created also a number of unread notification documents created for all the related users. When user reads a notification, the document is removed from mongo. Does this approach make sense? What are possible downsides?
The one issue I can think about is that user will probably have to fetch all of his unread notifications at once to be able to display witch of the real notifications are read. But it doesn't sound that bad.
Ok, think from a client perspective. I need to get my notifications in the lightest way possible. I don't want other people's notifications, I don't want to construct my data via aggregations.
Your Insert/create notification Meteor Method can have 2 function:
Insert the actual notification. If you have 10 people, 100 people, that is 10 ... 100 notifications.
On the user, write the increment of a notification count and eventually have it published with the other user details so that you can have it displayed.
When you open your notifications, you have a couple of options:
Read them all (write to db a "seen" or "read" field = Date.new() for these notifications. This field will help you style the notification as well seen - not seen.
Read on click of notification if in your UX a notification has to be opened. For example, I think in FB you have to click a notification to read it while in LinkedIn, opening notifications reads them all at once.
Use a library for in-view and only read those notifications that are in view, as you scroll in the list of notifications.
1 is the easiest to do and you also reset the counter on User to 0.
In summary, your insert notification method would be something like:
'methodName': async ({ notificationObject, userIds }) => {
...
userIds.forEach(id => {
- insert your notification
- increment user counter
- send a push notification
- or send an email
})
}
If you do this server-side and need to insert notifications from multiple methods such as: someone liked your something, someone sent a message to you etc... these are multiple methods that will be calling your insert notification method. In this case, if everything happens server side, better have the notification insert as a function instead of a method.
I have implemented the notificationhub service for Apple Push Notification (APNS) and I could able to send push notification to device successfully.
I am wondering where registrationId is stored in Azure, also how could I able to send push notification to specific device or user.
In the given following notificationhub tutorial, it is being used tag, but I am not sure if I use tag for each user or device is a right approach?
let tags = ["12345"]
https://learn.microsoft.com/en-us/azure/notification-hubs/ios-sdk-swift-rest
Tags can be utilized to essentially create target audiences for receiving a notification. A common enough use of tags is to target devices based on country, for example. So then you could have a tag like:
let tags = ["United States"]
or
let tags = ["Poland"]
This would require the country to be detected by code on the device and then calling the SDK to store that tag.
Tags are just opaque strings, though. So you can use them in whatever way you want. For example, you could also use them to target individual users across multiple devices.
let tags = ["myuser#foo.bar"]
Use tags that best allow you to target the audience you want to target. There are limits to tags though, you can only have 60 per device registration.
You can send to a particular tag (or a combination of tags called a tag expression) using the send API and providing a tag expression. There is a documented example of this available here: https://learn.microsoft.com/en-us/azure/notification-hubs/notification-hubs-tags-segment-push-message
And the actual API docs for it: https://learn.microsoft.com/en-us/rest/api/notificationhubs/send-apns-native-notification
You would be triggering the call to this API through some server-side component of your application and most likely not from the device itself.
I'm developing a standard video call application using Jitsi; I want an additional feature to let the other party know something lik "I'll be late a few minutes"
Jitsi has a built-in text chatting; but I don't know how it can be used outside the Jitsi call.
You can develop with "external_api.js". when current user joined the video jitsi triggers
participantJoined - event notifications about new participants who
join the room. The listener will receive an object with the following
structure:
api.on(‘participantJoined’, (object) => join(object.id));
resource
method will be triggered for each participant. Collect and store the participant "id"'s from there. Then use
sendEndpointTextMessage - Sends a text message to another participant
through the datachannels.
api.executeCommand('sendEndpointTextMessage', 'receiverParticipantId', 'text');
resource2
this method for sending messages for each participant.
You can develop with "lib-jitsi-meet"(lib-jitsi-meet) library and then you can use "sendTextMessage(text)" function.
We use the cumulocity REST API. Regular real time notifications work, e.g. we subscribe to /alarms/*, start our connection/polling loop and when we create an alarm we receive the expected JSON. We did not install any specific modules or statements, it just works.
But when we try to do the same with SmartREST we receive this error, as soon as the alarm is created:
40,,/alarms/177649296,Could not find any templates subscribed for the channel
Following the reference guide (http://cumulocity.com/guides/reference/smartrest/) we tried it like this, where all requests have the same X-Id-header and all requests result in the expected http status 200 and no error messages, except for the last one:
Register a smart response template by doing a POST to /s
Body: 11,102,,,$.channel
Handhake: POST to /cep/realtime
Body: 80
Response is our clientId (e.g. 191het1z38bp7iq1m96jqqt8jnef)
Subscribe: POST to /cep/realtime
Body: 81,191het1z38bp7iq1m96jqqt8jnef,/alarms/*
Connect: POST to /cep/realtime
Body: 83,191het1z38bp7iq1m96jqqt8jnef
In the normal REST case the notification consists of a JSON array with 2 elements, both of which have a property "channel". So that is what we would expect from our response template. Instead, we get the aforementioned error 40.
Is our response template wrong? Is it not properly matched by the X-Id? What does it mean, that there are no "templates subscribed for the channel"? The subscriptions are done for a clientId, and not for a specific response template, and the templates are supposed to be matched automatically anyway. So probably "template" means "X-Id" here? The documentation seems ambiguous as to the meaning of that word. But anyway, we did use the same X-Id header in all of the requests.
Any pointer about what we're doing wrong would be appreciated, since we tried pretty much anything by now.
The SmartREST protocol was developed for a IoT-device <-> platform communication. So there was never any design around using it to subscribing to realtime data (except of course for the operations a device needs) as usually devices to not need subscribe to the data that they created themselves.
That said it is possible to use it but with a couple of limitations. Your approach is basically correct but there is one problem with the subscription. The wildcard subscriptions will not work with SmartREST because on subscription it links your X-Id with the channel you subscribed to but there is never a message published on the channel /alarms/*. Thus this kind of weird error message that said that there was no template subscribed for the channel the alarm appeared on. Inside CometD you still receive the alarm because of the wildcard subscription but the SmartREST part does not work.
The messages are published on the channel with the deviceId (e.g. /alarms/12345).
If you subscribe to /alarms/12345 it will work. You can of course subscribe to as many channels as you want but wildcard subscription won't work.
Regarding the templates you need to know the following. The SmartREST parsing is not done on the raw JSON of CometD but on the payload inside it (e.g. the alarm). So a template for an alarm could look like this:
11,500,,$.severity,$.id,$.type,$.severity
This would trigger only if the object has a severity and would return id, type and severity.
I'm trying to implement the new analytics for a Facebook game (using HTML/Javascript and Flash on Canvas, so there is no mobile version), but it seems that the documentation is incomplete. It says that there are 14 predefined events:
"Events are one of 14 predefined events such as 'added to cart' in a
commerce app or 'level achieved' in a game"
Source: https://developers.facebook.com/docs/reference/javascript/FB.AppEvents.LogEvent
"The fourteen pre-defined events are: App Launch, Complete
Registration, Content View, Search, Rating, Tutorial Completed, Add to
Cart, Add to Wishlist, Initiated Checkout, Add Payment Info, Purchase,
Level Achieved, Achievement Unlocked, Spent Credits."
Source: https://developers.facebook.com/docs/app-events/faq
However, on the reference page where all the events should be listed, the list is only 12 items long, and there is no "App launch" event:
https://developers.facebook.com/docs/reference/javascript/FB.AppEvents.LogEvent#events
Now, there are some sample event lists for some games, but they are very basic and they don't include the actual code: https://developers.facebook.com/docs/app-events/best-practices#casual
which recommends to use these events:
App Install
App Launch
Completed Registration
Completed Tutorial
Level Achieved
Achievement Unlocked
(...)
Here is what I have so far:
FB.AppEvents.activateApp()
But is this event the equivalent of App Install or App Launch?
Also, should I send this before the user accepts to share his basic info or after? I'm having so many questions because it's not clear what activateApp() does...
Here is some code for sending some other events that could be useful:
FB.AppEvents.logEvent(FB.AppEvents.EventNames.COMPLETED_REGISTRATION);
FB.AppEvents.logEvent(FB.AppEvents.EventNames.COMPLETED_TUTORIAL);
var params = {};
params[FB.AppEvents.ParameterNames.LEVEL] = '12'; //player level
FB.AppEvents.logEvent(
FB.AppEvents.EventNames.ACHIEVED_LEVEL,
null, // numeric value for this event - in this case, none
params
);
I still have more questions: how can I properly send the game version number (maybe with activateApp?) so I can create segments and cohorts later? Some example codes would be really appreciated!
Thanks in advance!
FB.AppEvents.activateApp() provides install and launch event functionality, which is why those two events are not enumerated as options in https://developers.facebook.com/docs/reference/javascript/FB.AppEvents.LogEvent#events. Activate app doesn't take a parameter. You might want to look at using a custom event to satisfy your use case.