I'm writing a chromecast receiver application that will (hopefully) allow me to remotely put alert messages up on my TV to serve as reminders.
My plan was to have a dedicated wireless device on my home network that would constantly poll for new messages from a centralized server. When a new message was found, it would connect to a chromecast route, turning on the TV and displaying the new message.
But as far as I can tell, the only way to activate a chromecast route is by manually clicking the chromecast icon on my Chrome browser or wireless device.
Is there a way, programmatically, to activate the chromecast? Can it be done in the sender?
You can programmatically scan for cast devices and connect to them if needed. Steps are:
Get an instance of the MediaRouter singleton from the system: mMediaRouter
Build a selector:
mMediaRouteSelector = new MediaRouteSelector.Builder()
.addControlCategory(
CastMediaControlIntent
.categoryForCast(YOUR_APP_ID)).build();
Add a callback to initiate scan:
mMediaRouter.addCallback(mMediaRouteSelector, mMediaRouterCallback,
MediaRouter.CALLBACK_FLAG_PERFORM_ACTIVE_SCAN);
The onRouteAdded() and onRouteRemoved() of your callback (i.e. mMediaRouterCallback) will be called as routes are discovered or removed. You can maintain a list of routes in your app and keep them up to date by using these two callbacks.
You can select a route by calling mMediaRouter.selectRoute(aRouteInfo). Then the onRouteSelected() of your callback will be called and you can extract the cast device as usual and do as you please.
These said, remember that if you want to show a notification to users on TV your app should be running on the chromecast at the time you want to send the notification.
Related
I am currently building a Chrome extension that lets users auto-register for courses on a particular website once registration opens. The registration process is just a simple fetch POST request with an authentication header.
Now, this already works using the chrome.alarms API while the browser is open, but for obvious reasons I would want this to also work once the user closes the browser. Do you have any ideas how to do this? I really want to avoid to externally save user data..
If this is impossible, my idea would be to send the registration fetch to an external server (maybe even one hosted on a Raspberry Pi? Other ideas?) and then execute it once the registration opens.
When the user downloads the app and opens it for the first time, a splash screen should show telling him to log in or other stuff. Then, every time the user re-open the app it should check for if the user is authenticated or not.
Can I do this with hydrated_bloc?
If you are using Firebase backend then on each launch of the app you will call firebaseInstance.currentUser() to check if authorized or not and this check will be through an event from the bloc when the app launches
If you are not using this backend then also on each launch of the app you will call some method to check if auth token (if exists) is still valid also through an event from the bloc
Now the HydratedBloc can save the previous state of the app but suppose you save the previous state and the user doesn't open the app until after token expires and you are using HydratedBloc so you will only rely on it to check the previously saved state (auth status) and not use the methods above so in this case you will login an UNAUTHENTICATED user into the app.
And if you say I will also do the above methods then what is the point of using this bloc in this case?
So looks like it is an overkill to use this bloc for this feature
I have a question about Push Notifications. As far as I know, when the App starts, it checks if exists a push channel and, if not, it creates a new channel. Also there is an event which starts when the uri is changed. And this Uri gets expired after 30 days.
But what I would like to know is: I want to send these notifications even if the user does not have the app running (let's suppose for a long time, more than 30 days).
Is posible to detect the Uri changed if the App is not running?
Could I force somehow device uri update?
EDIT:
I have read this information:
Each time your app starts, you should pass the URI from your push
channel to the cloud service that sends out the push notifications. It
is also recommended that you pass the device ID to your cloud service
so that the cloud service can track to which devices the URIs are
assigned. If a URI changes, then the cloud service can replace the old
URI for that device ID. Windows Phone does not provide a framework to
do this, since in most scenarios apps and cloud services already have
their own protocols that they use to communicate with each other.
From here
According to the text, my cloud service could send the new URI to the device, instead of updating the uri from the client? If so, do you know how could I do this?
I would like to know what is the clean & correct way to notify my WP8 app that the ChannelUri has changed?
I read that i need to handle this in the ChannelUpdatedUri method. But i have a few queries here. Doesn't this require my app to be running all the time?
Second query is suppose i use ChannelUpdatedUri to listen for changes to the Uri. If there is a change will the app be notified as soon as it launches? Or will it be notified at a later time?
The trouble is if the app is not notified on launch then there is a possibility that it may re-register for a new channel uri before ChannelUpdatedUri is invoked. Isnt it?
Please help!
You'll only get notified of a change in the ChannelUri when you have the listener attached and the app running.
The best approach is to always check for the current Uri and pass it to the server when the app starts. You could leave the listener attached for the lifetime of your app and get a new one if it's lost while the app is running but in reality it's far more likely that the channel will be dropped/disconnected when the phone isn't in use.
There is, of course, the scenario where a channelUri may expire when the app isn't in use but the utility of the app is primarily around sending notifications. Obviously you need the user to restart the app to get a new connection but you can't tell them to restart the app.
This is a generic problem: how do you tell someone that you can't talk to them?
The reality of this situation is that if you really need to tell someone to launch the app again you'll need another way to do it.
Unfortunately, it's not possible to get an updated channelUri from a background agent, but you could query your backend to see if you need one and then raise a toast to the user to prompt them to reopen the app. Or you could just update the tile from the agent when this happens.
Alternatively you'll need to send them the prompt in another way (e.g. email or SMS?) but this is reliant on you capturing and securely storing these details.
There is no perfect solution to this scenario other than creating an app that the user opens regularly regardless of whether there are notifications or not and simply having the notifications as an extra feature.
I have metro application in which I implemented Push notification concept for getting single message.If I get more than 1 notification,still my application tile is able to show only 1 notification(msg).Am not able to do how to display multiple notifications for time-specific.Means do I need to write any extra code for displaying multiple notifications on my tile.If so, where should I need do write either client-side or server-side?
Thank you.
There are several ways to look at updating, and depending on what your end goal is, you may end up implementing the code either on the client, or the server, or a little of both.
For the scenario you describe, you need to use Windows Notification Services to push the notification each time you want a new tile notification. Typically, this is done by having a service running in the cloud (a website, or a Windows Azure service, or similar), that calls Windows Notification Service and sends a tile update to the app when something of interest occurs.
If what you want is for multiple notifications to cycle on the tile, that's enabled by calling the enableNotificationQueue method on the TileUpdater class:
http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.notifications.tileupdater.enablenotificationqueue.aspx
Per the comment below, enableNotificationQueue works for any notification source. But if you want to pull information from a remote service, rather than using push, you can use scheduled polling as means of updating the tile using remote information, as described here:
http://msdn.microsoft.com/en-us/library/windows/apps/Hh761476.aspx
Combined with the call to enableNotificationQueue, it may also enable the scenario you're looking for.