Add a close button for a task module in ms teams - microsoft-teams

I am investigating if it's applicable to have a cancel/ close button on our html page inside taskmodule so it can actually close the task module?

Yes, it's entirely possible to do this. Basically, in order to close your task module in any way, you make a call from within the web page (in script), to:
microsoftTeams.tasks.submitTask
submitTask takes two parameters. The first is any object you want to return back to the caller (whatever opened your task module). For instance, if you have a Tab in your app, and the Tab opens the task module to app a new entry to a database, you could pass that new item back to the opening Tab by passing it as microsoftTeams.tasks.submitTask(newItem);
You can see more about this here.
If you have nothing at all to send back, you can simply call microsoftTeams.tasks.submitTask(null);. In this case, it will do nothing but close the task module, which sounds like what you're trying to do.

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.

How to run command when popup shows up?

I need to execute a command when popup shows up, like Loaded event, how can I do that? Do I need to override PopupWindowAction or it's supported already?
An interaction request is normally raised from code - execute the command just before raising the request, if that's possible.
Or you can execute it from the constructor of your popup's view model, that should happen a litte later.
As a last option, you can react to the Loaded event of your popup's content.
Another last option would be to override PopupWindowAction.CreateWindow and attach a handler to execute your command, but I'd prefer one of the code-only options that work without the actual view.

Async cancellabel task

I want to implement a behaviour for my application that at the start checks a webservivce if any news are available. If there are news available, pop open a screen to show to the user. If there are no news available, or the user quits the application (or starts the game) i dont want to bother the user but instead cancel the task to retrieve the news item
I thought it would be a breeze doing this with the Task Library but unfortunatly it is not available in the default loadout on Windows Phone (or is it?).
I think the key here is the cancelable part. I certainly know how to start an async op, but what is the best practice for hte cancelable part?
The Task Parallel Library is available for Windows Phone, in this NuGet package: System.Threading.Tasks.
But I don't really get why you care to cancel the task. If the user quits the application, the task end, and if you do another action, nothing happens.

How to show a Carbon dialog as part of a plugin for an application with an existing event loop?

I'm writing a plugin for an application and need to use Carbon to show a dialog. I have everything set up including the event handler, but I cannot possibly call RunApplicationEventLoop() because this would stall the host application.
How can I fix this? Will I need to create a separate thread and call RunApplicationEventLoop() from there?
-Joe
What makes you think you need to call RunApplicationEventLoop? The host app is presumably running an event loop, probably either using RunApplicationEventLoop or NSApplicationMain. By the way, would your dialog be modal? Modal is easier.

netServiceBrowserDidStopSearch not called

I'm now writing a Bonjour service listener class, according to the document here:
Currently, it seems working, I can receive "netServiceBrowserWillSearch:" and "didFindService:moreComing:" correctly. However, after a long wait, I cannot receive " netServiceBrowserDidStopSearch:" or "netServiceBrowser:didNotSearch:". Therefore I don't know that is the proper time for my delegate class to stop showing some UI.
Could anyone have an idea for this? Thanks.
NSNetServiceBrowser doesn't stop browsing (and call the -netServiceBrowserDidStopSearch: delegate method) until you explicitly tell it to by calling -stop. After it's found the initial services, it continues informing you as new matching services are added or old ones disappear.
How you handle this depends on how you want your app to behave. If you have a window that continuously shows the available services (e.g. like the Bonjour window in iChat), then it's best to let it continue, and contiuously update the list in response to delegate messages. If you've got more like a dialog that gets populated and then goes away once the user makes a selection (e.g like the system Add Printer... dialog), then you want to keep the browser running while it's displayed, then call -stop once the user dismisses it. If you're waiting to find just one specific service, then you can call -stop once you've found and resolved it.

Resources