LG WebOS 3.0 TV App Exit Button Close App and - exit-code

I am developing a TV app for LG 4K TVs in webOS 3.0.
self_evaluation_checklist_3.4.xlsx lists a requirement for Exit button behavior as below.
"For webOS 3.0, pressing the EXIT button the app is completely closed and does not remain on the Recent list."
I have been searching but I haven't had any luck finding the API call to close the app completely and also removes the app from the Recent list.
All I could find is webOS.platformBack(); but that only takes back to the Home screen of the TV and doesn't close the app.
How can I close the app completely and don't list the app in the Recent list?

This is correct method ( webOS.platformBack(); ).
At least our app uses the same method for all 3 generations of WebOS and has never been declined by LG QA Center for this.

To exit the app and leave it in the Recent list I used the following:
const APPLICATION_MANAGER_SERVICE = 'luna://com.webos.applicationManager';
const TV_APP_ID = 'com.webos.app.livetv';
function sendAppToBackground() {
webOS.service.request(APPLICATION_MANAGER_SERVICE, {
method: 'launch',
parameters: { id: TV_APP_ID },
onSuccess(response) {
if (response.returnValue === false) {
console.error(`Error sending Application to background and bringing TV Application with ID ${TV_APP_ID} to the foreground.`);
forciblyExitApp();
}
},
onFailure(error) {
console.error(error);
forciblyExitApp();
},
});
}
function forciblyExitApp() {
window.close();
}

Related

tabs onUpdated event not detected on Safari extension?

I am trying to develop a simple web extension/addon under Safari, which is using the tabs onUpdated event. I used the Safari XCRUN converter: https://developer.apple.com/documentation/safariservices/safari_web_extensions/converting_a_web_extension_for_safari
What I am trying to do is :
Open new tab on Google Scholar with set prefs params, from "options.js" script (Options page code below)
Listen for this tab to be updated and ready (e.g. tab status is complete)
Then, inject a content script that will simulate the user click on save button (i.e. on GScholar page)
Then remove the listener, and wait 1,5s (for GS tab to reload and finish saving) in order to finally close this tab.
// Detect browser language
const gsUrl = currentBrowser.i18n.getUILanguage().includes("fr")
? GSCHOLAR_SET_PREFS_FR_URL
: GSCHOLAR_SET_PREFS_COM_URL;
// Listener to detect when the GS tab has finished loading
const gsTabListener = (tabId, changeInfo, tabInfo) => {
if (changeInfo.url && changeInfo.url.startsWith(GSCHOLAR_HOST)) {
currentBrowser.tabs.executeScript(
tabId,
{
code: `document.getElementsByName("save")[0].click();`,
},
() => {
currentBrowser.tabs.onUpdated.removeListener(gsTabListener);
setTimeout(() => currentBrowser.tabs.remove(tabId), 1500);
}
);
}
};
currentBrowser.tabs.onUpdated.addListener(gsTabListener); // Add tab listener
currentBrowser.tabs.create({
url: `${gsUrl}?inst=${gScholarInstIdList.join("&inst=")}&save=#2`,
active: false,
}); // Open GS tab according to browser language
The problem is that it works well on Chrome/Edge/Firefox (on MacOS), but not on Safari : the GS tab is opended but isn't closed and nothing happens :-/
PS:
It seems tabs onUpdated event is well supported on Safari according to MDN.
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/tabs/onUpdated
I have also tried webNavigation onCompleted event, but same !
Developing on : MacBookAir under MacOS Monterey 12.4, Safari 15.4 (17613.2.7.18), XCode 13.3.1 (13E500a), extension is bundled with Webpack 5.68.0 (e.g. building all assets files).
I really don't see what I am doing wrong and why wouldn't this tab event be intercepted ?
Thanks for your feedback.
After debugging I finally sloved this by noticing that in fact the events were triggered, but missed because of the availability and values of parameters passed into callabck (changeInfo, details) depending on the browser we're on.
So I switched from onUpdated to webNavigation.onCompleted API, which is better suited to our need (tab page fully loaded) and whose parameter is simple and consistent across browsers :-)
const uiLanguage = currentBrowser.i18n.getUILanguage().includes("fr")
? "fr"
: "com"; // Detect browser language
const gsUrl = `${GSCHOLAR_SETTINGS_HOST}.${uiLanguage}`;
// Listener to detect when the GS tab has finished loading
const gsTabListener = (details) => {
if (details && details.url && details.tabId) {
if (details.url.startsWith(`${gsUrl}/scholar_settings?`)) {
currentBrowser.tabs.executeScript(details.tabId, {
code: `document.getElementsByName("save")[0].click();`,
});
} else if (details.url.startsWith(`${gsUrl}/scholar?`)) {
currentBrowser.webNavigation.onCompleted.removeListener(
gsTabListener
);
currentBrowser.tabs.remove(details.tabId);
}
}
};
currentBrowser.webNavigation.onCompleted.addListener(gsTabListener); // Add GS tab listener
currentBrowser.tabs.create({
url: `${gsUrl}/scholar_settings?inst=${gScholarInstIdList.join(
"&inst="
)}&save=#2`,
active: false,
}); // Open GS tab according to browser language

Why Teams API for web Apps crashes IOS Teams app?

We have an app published in the Teams App Store which uses task module and tabs.
On Task/Tab pages we use Teams API lib to work with media (camera/gallery). Camera and gallery API works fine if we limit users to only one image to pick.
On Android everything works great (doesn't matter how many media files you pick).
Strange things happen when we let IOS users to pick/make more than one image at a time.
There are two possible scenarios on IOS devices:
Teams App crashes.
Teams API returns attachments.length !== blobs.length.
I did some tests on different IOS Devices. Both have issues. I've updated the app to the latest and it got even worse (started to crash more often):
iPhone Xs (IOS 15.1).
iPhone 11 Pro Max (IOS 15.1).
Steps to reproduce blob issue:
Create an HTML page and load it into Task module.
Trigger microsoftTeams.media.selectMedia with maxMediaCount: 10.
Pick up to 10 small size images.
Save received attachments.length.
Request a blob for each attachment.
Calculate how many blobs and attachments you've got.
Expected: blobs.length === attachments.length.
Result: blobs.length !== attachments.length.
The issue described above appears randomly, sometimes you get expected values, sometimes you don't, sometimes it crashes even with small images.
How to crash IOS Teams App, Steps to reproduce:
Create an HTML page and load it into Task module.
Trigger microsoftTeams.media.selectMedia with maxMediaCount: 10.
Pick up to 10 big size images.
Expected: "Error 10000, Selected file is too big".
Result: Teams App crashes.
My code:
const MEDIA_MAX_FILES = 10;
const imageProp: microsoftTeams.media.ImageProps = {
sources: [microsoftTeams.media.Source.Gallery],
startMode: microsoftTeams.media.CameraStartMode.Photo,
ink: false,
cameraSwitcher: true,
textSticker: true,
enableFilter: true,
};
const mediaInput: microsoftTeams.media.MediaInputs = {
mediaType: microsoftTeams.media.MediaType.Image,
maxMediaCount: MEDIA_MAX_FILES,
imageProps: imageProp
};
const attachementsList = [];
const blobs = [];
microsoftTeams.media.selectMedia(mediaInput,(error: microsoftTeams.SdkError,
attachments: microsoftTeams.media.Media[]) => {
if (error) { /* block is truncated */ return; }
if (attachments) {
attachementsList.push(...attachments);
for (const attachment of attachments) {
attachment.getMedia((attachmentError: SdkError,
blob: Blob) => {
if (blob) {
blobs.push(blob);
}
});
}
}
});
Teams App build versions. Dev Preview is turned on on both devices:
iPhone Xs: 3.20.77.2021202701/1121
iPhone 11 Max Pro: 3.20.77.2021202701/1121
Is this a bug ? Or am I doing something wrong ? Thanks in advance.

LGTV -WebOS - Is there a way to open an URL on the TV browser?

I am developing a web hosting app for the LG/TV WebOS.
I know that the web hosting app is basically running inside a browser engine (webkit?).
When the user is about to make the payment (I am using Paypal because I don't like PaymentWall), the app directs the user to the paypal confirmation page where there is no mean for the user to click on the CORFIRM PURCHASE button. I don't see the "mouse" cursor and there is no documentation I could find about the theme.
So, I was thinking if I could launch that payment page on the tv's browser.
That browser has a cursor that moves when I click the arrows.
Any way to do that? To launch an URL from the app into the television browser? or to make the cursor appear inside the app?
I used this approach.
openLink(url: string): void {
webOS.service.request("luna://com.webos.applicationManager", {
method: "launch",
parameters: {
id: "com.webos.app.browser",
params: {
target: url,
},
},
onSuccess: (res: any): void => {
console.log("Browser open success. ", res);
},
onFailure: (res: any): void => {
console.log("Browser open fail. ", res);
},
});
}
It requires webOS.js or webOSTV.js library.
Personally, I use the following library to enhance navigation for web based applications.
https://github.com/luke-chang/js-spatial-navigation
It creates fluid navigation between UI elements using just the arrow buttons.
The user experience is basically identical to that of native applications like Netflix.

Firefox WebExtension notifications API: How to call a function when the notification is clicked

I'm trying to develop a Firefox add on using WebExtensions. What I'm trying to do is open a new Firefox tab or window when the user clicks the notification. But it doesn't work.
When I click the notification, nothing happens.
I'm creating notifications like:
var q = chrome.notifications.create({
"type": "basic",
"iconUrl": chrome.extension.getURL("128-128q.png"),
"title": 'title',
"message": 'content'
});
chrome.notifications.onClicked.addListener(function(notificationId) {
window.open('http://www.google.com');
});
browser.notifications.onClicked.addListener(function(notificationId) {
window.open('http://www.google.com');
});
q.onClicked.addListener(function(notificationId) {
window.open('http://www.google.com');
});
var audio = new Audio('message.mp3');
audio.play();
How can I make this work?
It appears that the problem is that you are attempting to open a new URL in a way that does not work.
The following should work, using chrome.tabs.create():
var q = chrome.notifications.create("MyExtensionNotificationId", {
"type": "basic",
"iconUrl": chrome.extension.getURL("128-128q.png"),
"title": 'title',
"message": 'content'
});
chrome.notifications.onClicked.addListener(function(notificationId) {
chrome.tabs.create({url:"http://www.google.com"});
});
However, you need to be testing this in Firefox 47.0+ as support for chrome.notifications.onClicked() was only added recently. My statement of Firefox 47.0+ is based on the compatibility table. However, the compatibility table has at least one definite error. Thus, a higher version of Firefox may be required. The code I tested worked in Firefox Nightly, version 50.0a1, but did not work properly in Firefox Developer Edition, version 48.0a2. In general, given that the WebExtensions API is in active development, you should be testing against Firefox Nightly if you have questions/issues which are not functioning as you expect. You can also check the source code for the API to see what really is implemented and when it was added.
Note: this works with either chrome.notifications.onClicked or browser.notifications.onClicked. However, don't use both to add two separate anonymous functions which do the same thing as doing so will result in whatever you are doing happening twice.
I did not actually test it with your code, but I did test it with a modified version of the notify-link-clicks-i18n WebExtensions example. I modified the background-script.js file from that example to be:
/*
Log that we received the message.
Then display a notification. The notification contains the URL,
which we read from the message.
*/
function notify(message) {
console.log("notify-link-clicks-i18n: background script received message");
var title = chrome.i18n.getMessage("notificationTitle");
var content = chrome.i18n.getMessage("notificationContent", message.url);
let id = "notify-link-clicks-i18n::" + title + "::" + message.url;
chrome.notifications.create(id,{
"type": "basic",
"iconUrl": chrome.extension.getURL("icons/link-48.png"),
"title": title,
"message": content
});
}
/*
Assign `notify()` as a listener to messages from the content script.
*/
chrome.runtime.onMessage.addListener(notify);
//Add the listener for clicks on a notification:
chrome.notifications.onClicked.addListener(function(notificationId) {
console.log("Caught notification onClicked with ID:" + notificationId);
//Open a new tab with the desired URL:
browser.tabs.create({url:"http://www.google.com"});
});
My preference for something like this where a unique ID is possible is to provide a unique ID, that both identifies that the notification was displayed by my add-on and what the notification was. This allows the listener function to choose to only act on notifications which were displayed by my add-on and/or only a subset of those I display, or have different actions based on why I displayed the notification.
The reason you had trouble here in figuring out what was not working is probably because you did not reduce the issue to the minimum necessary to demonstrate the issue. In other words, it would have been a good idea to just try opening a new URL separately from the notifications onClicked listener and just try a console.log() within the listener.

desktop notification api for windows

Are there any windows software that i can use that can connect with my website via API where there is a customizable feature for desktop notifications?
Alternatively, are there any hacks i can use to make the width of the chrome desktop notification larger?
I tried using html but this just prints as a string.
function notifyMe() {
if (!Notification) {
alert('Notifications are supported in modern versions of Chrome, Firefox, Opera and Firefox.');
return;
}
if (Notification.permission !== "granted")
Notification.requestPermission();
var notification = new Notification('Notification title', {
icon: 'http://www.metoffice.gov.uk/media/image/j/i/Cumulus_2.jpg',
body: "<div style='width:700px'>You've been notified!</div>",
});
notification.onclick = function () {
window.open("http://www.google.com");
};
}
Any suggestions.. i want a customizable size notification?
You can't change the size of Chrome-provided notifications.
You can use an extension + Native Messaging to pass something to a native application of your choice (maybe through a "proxy" script, as Native Messaging is limited).

Resources