Programmatic way to switch apps?
I have done some debugging using lightning inspector and found out what event is fired when we click on a app in app launcher.
So event fired is force:switchApp with parameters
var appEvent = $A.get("e.force:switchApp");
appEvent.setParams({
"tabsetId": "02uU0000000DtzAIAS",
"startUrl": "/one/one.app#/sObject/02uU0000000DtzAIAS"
});
appEvent.fire();
One thing I was not able to find out how to get tabsetid. TabsetId is of sobjectType TabSet. But TabSet cannot be queried. :( I queried appDefination and tabDefination but no luck there also. So only way to find tabsetId is using lightning inspector and then go to event log and find app id.
Edit
As suggested by Charles in comments we can use tooling api to get app id using
SELECT AppId, Label, Active, SortOrder FROM MenuItem WHERE MenuType = 'AppSwitcher'