Android MediaRouter - appcelerator

I try to build a Titanium module for Mediarouter (Chromecast). The standard solution for it is the use a MediaRouteSelector that opens a dialog with elements of android-support-mediarouter.jar. If I build a demo app by using the chromecast module then the aapt tries to resolve dependencies to appcompat-v7. But a module can only work with one res folder.
My question: is it possible the get a mediaroute without UI? I mean to ask the android and the system give me a collection of connected devices (name and id), I build an own dialog box and the result of users select calls a method to commect with this selected device. This solution would avoid the res conflict.
Here the repo: https://github.com/AppWerft/Ti.Chromecast/tree/master/android
Thanks

MediaRoute has nothing to do with the UI itself. You can initiate a discovery on the local network for the routes that satisfy your search criteria and then register to be notified when a matching route is found or dropped out, etc. If you want to show your own UI, you'd need to manage the list yourself, both in terms of bookkeeping, interactions and presentation. Look at our Android sender documentation or one of our Android sample apps (e.g. MediaRoute-Cast-Button sample) to get an idea.

Related

How to be sure, that web application (html/js) is open in Task Module?

I have created a message extension app for MS TEAMS. I use Task Module. And a single page application was created especially for this message extensions. It works. I just do NOT want that single page application can be opened in a browser. It should work only inside the Task Module. Is any possibility to do that?
Have a look at the Teams client SDK, especially microsoftTeams.getContext. You could do something like have your content hidden, or empty, and then only call your API/show your content/whatever, when the getContext returns.

NSURLSession with share extension returns -995 on OSX

I'm trying to upload data using NSURLSession with a background task from an OSX share extension.
As soon as I start the task, by delegate is called back with the world's least helpful error message:
The operation couldn’t be completed. (NSURLErrorDomain error -995.)
There's no other information in the NSError object, nor in the console.
After scouring the internet, the only clue I have is to make sure that I've set up the configuration.sharedContainerIdentifier correctly, however I've already done that:
let configuration = NSURLSessionConfiguration.backgroundSessionConfigurationWithIdentifier(uniqueId)
configuration.sharedContainerIdentifier = Config.appGroupName
urlSession = NSURLSession.init(configuration: configuration, delegate: self, delegateQueue: nil)
I then prepare the request and create the task:
let task = self.urlSession!.dataTaskWithRequest(request)
self.tasks.append(task)
task.resume()
Note that everything works perfectly when from my main app. It's just the sharing extension that fails.
What other problems could cause error -995?
(Bear with me, I don't have rep yet for a comment so I have to answer, and notwithstanding the possibility you've found a bug, the last part I'm adding might help others)
When you're using an NSURLSession any background upload/download that completes will launch your main application. This is detailed in the Common Scenarios page.
As you show you've done, you need to set the NSURLSessionConfiguration with a sharedContainerIdentifier:
let configuration = NSURLSessionConfiguration.backgroundSessionConfigurationWithIdentifier(uniqueId)
configuration.sharedContainerIdentifier = Config.appGroupName
urlSession = NSURLSession.init(configuration: configuration, delegate: self, delegateQueue: nil)
You also need to ensure that both your app extension and your main app are all triple-checked in the 'App Groups' option in Xcode (I'm looking at Xcode 8.1), which means:
The app group name is the same for both app and extension(!)
the check beside Add the App Group entitlements in the entitlement file
the check beside Add the App Groups feature to your App ID
the check beside Add App Groups to your App ID
And the checks need to be there on both app and extension.
I'm a bit rusty on adding these but my recollection is these aren't listed in the right order, e.g. you have to 'Add App Groups to your ID' before you can check them in both app and extension, but I could be wrong.
Advanced - Thirdparty libraries in app extensions.
Looking at the github project nst/STTwitter, a third-party Twitter REST library, they needed to add a configurable group ID to allow setting the NSURLSessionConfiguration sharedContainerIdentifier to the library user's group ID.
I may again be mistaken but this seems like it would be a general problem when using thirdparty libraries in an app extension - e.g. I've just now come across this error when trying to use the ChromeCast SDK and this could be the kick in the pants.

Branch.io: detect first install from Unity

Trying to detect the first install event from branch.io link (succesfully implement link creating and sharing). I am using Unity branch sdk. The feature i try to create:
user_1 creates and share link to user_2.
When user_2 opens the link and install app i need to reward both of them (with inner in-game coins)
So i succesfully implement the 1. but I cant understand how to detect is user_2 installs the app or simply open it. All data that comes from branch.io UniversalObject callback doesn't contain information that i need.
Which the correct way to detect the install from code?
Alex from Branch here.
The callback parameter you need is +is_first_session. This is one of the parameters returned when the Branch session is initiated each time your app opens (you can find all all these parameters here). If this returns true, then that device has just installed the app (instead of opening it).
However, note that when these parameters are returned, it's impossible to immediately determine if the user is new (what you want), the device is new (not what you want, since the reward could be given twice if the user has installed on multiple devices), or neither (the user deleted the app and reinstalled on the same device). You would probably want to hold off on actually awarding the referral points until after the user has logged in with some sort of unique ID.
Branch also has a built-in feature for tracking referral points that might be useful. That lets you configure all the rules using the dashboard UI instead of needing to do it programmatically inside your app.

Clean UI elements watchOS 2 after lock

When the app starts is Apple watchOS2 it calls:
awakeWithContext
Then, if you lock and unlock the app, the lifecycle calls:
willActivate
The problem that I have is that I cannot remove the UI elements (clean screen), without user see the "old" screen during 1 second.
From the Apple documentation:
didDeactivate:
-Do not use this method to modify your interface......Modifications can be made only during initialization of your interface controller and between calls to willActivate and this method.
but then in willActivate method:
.... Do not use this method to perform the initial setup of your interface.
I don't know what I have to do to "clean" the screen when the user locks the app.
Thanks for your time.
The answer from Apple:
Thank you for contacting Apple Developer Technical Support (DTS). Our engineers have reviewed your request and have concluded that there is no supported way to achieve the desired functionality given the currently shipping system configurations.

How to specify no actions for android wear notifications?

I have a couple actions for my notifications, however I don't want any of them available on android wear. I know I can specify a list of custom actions for android wear, but how do I specify none? (I've tried addActions with an empty list, but no luck - then it just shows all the actions)
I don't think this is possible in standard way. If you specify at least 1 action in WearableExtender then normal actions will be replaced with wearable actions, but as you've said - you want to have 0 wearable actions.
For me you have 2 solutions:
Go with the API design post alternative versions of actions with your WearableExtender. If really any of phone actions cannot be used on watch maybe you can think of anything else that would be useful. It won't hurt user to be able to perform any action from watch. Of course if that makes sense in your case.
If you want to "hack" it a bit you can "clone" the notification and make them a part of the same group. If you would set one as a "group summary" that one will show up only on phone and other will be visible only on wearable. That way you have ability to setup completely independent set of actions.
Sample code:
NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
// configure your builder without actions
builder.setGroup(GROUP_TAG);
builder.setGroupSummary(false);
notificationManager.notify(WEARABLE_NOTIFICATION_ID, builder.build());
// add some actions that will be visible only on phone
builder.addAction(...)
builder.addAction(...)
builder.setGroupSummary(true);
notificationManager.notify(PHONE_NOTIFICATION_ID, builder.build());

Resources