I have an existing handling for push notification directly sent from our backend server. But now, I want to support urban-airship for push delivery without breaking existing flow.
So I have defined an IntentReceiver for UA notification (besides existing GcmIntentReceiver). But the problem is, now both the receivers are getting invoked. How can I determine and skip any particular callback depending upon which delivery method is used?
The easiest way would be to use 2 different senders. Create a new sender for Urban Airship and set as the 'gcmSender', then add your existing sender as an 'additionalGCMSenderIds' in the Urban Airship config. This will allow Urban Airship to register both senders for the application, and UA will only handle intents form the 'gcmSender'. Then in your existing GCM intent receiver you need to filter out intents from the Urban Airship sender ID by checking the "from" extra on the intent.
String sender = intent.getStringExtra("from");
if (APP_SENDER.equals(sender)) {
// GCM Intent from your existing sender
}
Related
Is it possible to send an external message (e.g., and email or SMS text, tweet, etc.) via R without providing a sending account?
If so, how would one send a quick message to an email account or mobile device using R in such a way that doesn't require a sender account input?
Example usage: to inform user when code is done running.
I've seen other SO posts discussing how to send emails (e.g., here and here) and texts via R, but none of these sources discusses the possibility of doing so without providing an explicit sender account (i.e, credentials).
Disclaimer:
This is not for sneaky business, but rather to simplify security/privacy.
I just finished one SignalR sample, the well-known Chat sample.
This sample just broadcast a chat message from one client to all the clients. What if we want to send message to only a specific client?
(I guess there should be some ID to identify each client. These IDs should be stored on server when clients subscribe to the server. And server can choose which ID to push message to. )
You have different way to map your user with a connection. You can compare the different ways in this tutorial depending on your requirements.
Another solution is to define 1 group per userId and notify the group when you want to notify a user (link). Be careful, groups are not secured.
Like Daniel describes you can use a group or use the hubcontext to get the context for a specific connection using the connection Id.
var client = context.Clients.Client(connectionId);
There are also several libraries that abstract SignalR, some of these comes with their own way of calling specific users.
I have made a library like this which is based on the Event aggregation pattern. It comes with a API to let you create code that determines which clients should receive a specific event
https://github.com/AndersMalmgren/SignalR.EventAggregatorProxy/wiki/Implement-constraint-handlers
Here is also a blog post I made showing how you can achieve declarative role authorization with my library, maybe it can give you some ideas.
http://andersmalmgren.com/2014/06/12/client-server-event-aggregation-with-role-authorization/
I wanted to send out data to a specific client on a channel using the Ajax Push mechanism. Here's my design: I have say 10 clients subscribed to Channel #1, and 10 more subscribed to Channel #2.
I want to send out an Ajax Push when some particular parameter is updated in my database. I want to send it out to say client #7 on Channel #1. In Ajax Push,I know I can send out the Push to all subscribers of Channel #1. Is there any way to send out the Ajax Push to ONLY client #7 on Channel #1?
Thanks,
Thothathri
You really do what do have a separate channel for each user. Channels are very cheap with WebSync; even if there was a built-in way to send data to a specific user, it would be implemented exactly in that manner. Having 1000 channels is not a big deal; recently I had a discussion with one user who had something like 10,000 channels per connected client (which is pretty extreme, to be fair), but was working without a hitch.
Simply create a channel such as /user/{username} and use that to push to that user specifically, and you'll be good to go.
If you subcribe a Consumer in Flex, you need to assign a ChannelSet to the Consumer. In my case, I create a ChannelSet and then add a Channel to that ChannelSet.
Apparently, the added channel is the current channel of the ChannelSet. But what if I would add two Channels to the ChannelSet? Do I need to set the currentChannel before subcribing?
If there are two channels in the ChannelCet, and I trigger the login method on the ChannelSet, will both Channels be authenticated and connected?
The ChannelSet will use the Channel that was added first and fall back to the other channels in case a Channel cannot be reached. The currentChannel property is a read-only property that points to the channel currently in use.
Here's the info from the docs:
Regardless of clustering, if a Channel
cannot connect or looses connectivity,
the ChannelSet will advance to its
next available Channel and attempt to
reconnect. This allows the ChannelSet
to hunt through Channels that use
different protocols, ports, etc., in
search of one that can connect to its
endpoint successfully.
About logging in: calling login() on the ChannelSet will use the same linear lookup of Channels and will authenticate on the first Channel. If you add another channel, it will be added to the list of channels and if it needs to be used, the ChannelSet will authenticate on the new Channel as well (since the credentials are saved). At least, that is what I can deduct from looking at the code of ChannelSet in the Flex SDK.
I'm trying to create a module for a flex application, and I want to send notifications to clients. I've been looking at the BlazeDS messaging service to push out the notifications to clients, but I want to be able to send certain updates to certain clients. The Flex notification framework doesn't seem to allow this - if we have a field in the message with a value of the user's user id for example, any client could theoretically subscribe to all messages for any given user id, and there's no verification on the server side to make sure that the client that has subscribed is logged in as that user id.
Is there something I've missed here, or is the best way to handle this writing my own polling mechanism on the client side?
There is indeed a solution for this in the APIs. The first step is to write a class which extends the FlexClientOutboundQueueProcessor class. You need to override one method:
public void add(List outboundQueue, Message message);
Basically all you need to do is write some logic to determine whether you should make the following call:
outboundQueue.add(message)
Simply put, if you don't add the message to the queue, then the message won't be pushed to the client. The other important method in this class is:
FlexClient getFlexClient()
Which you can use to get the associated FlexSession and ultimately the authentication information that presumably exists in your app.
Once this is done, you just need to register the processor with the appropriate channels. Simply add this element within the "properties" element of the "channel-definition" element:
<flex-client-outbound-queue-processor class="com.foo.YourProcessor"/>
I believe you can also specify a nested "properties" element for the queue processor but I don't believe it's required.
You can use subtopics for this as long as you disable wildcard subscriptions.