I want to click a link that launches an app on Android. However, if the app is not installed, by default Android redirects to the Play store. I don't want this.
What I want is to be able to redirect to a custom webpage if the app is not installed. iOS seems to support this by using setTimeouts but according to this page https://vhudyma-blog.eu/open-mobile-application-from-the-browser/ there is no similar flow offered for Android. Thank you for your help.
if (isAndroid) {
const url =
"intent://instagram.com/#Intent;scheme=https;package=com.instagram.android;end";
// open the app
// if the app isn't installed, it seems we just go to the play store
window.location.replace(url);
} else if (isIOS) {
// go to the app
window.location.replace("instagram://");
// open the app store on a timeout. this will happen but not be seen if instagram has opened
setTimeout(() => {
window.location.replace(
"https://apps.apple.com/us/app/instagram/id389801252"
);
}, 10000);
} else {
// we're not in ios or android so just go to the website
window.location.replace("https://instagram.com");
}
You might have a little luck with getInstalledRelatedApps()
const list = await navigator.getInstalledRelatedApps();
Here is an article about it: https://web.dev/get-installed-related-apps/
Even though it might not be too wildly supported.
I'm building a new version of a Cordova project that uses the push notifications for the first time. I use the 'cordova-plugin-firebase' version 1.0.5 for handling them. Everything works fine on Android, but on iOS I seem to have a problem. If I download the official app from AppStore and then upgrade it with the new version via XCode, the push notifications doesn't seem to work (no "message" appears at the top in iOS). If I have the app opened, the XCode debugger prints the push notification and it looks like this:
{
"collapse_key" = "bundle_ID";
from = FIREBASE_ID;
notification = {
body = "This is a message";
title = "Message";
};
tap = 0;
}
If I then close the XCode project and create a new one (or open this newly created one again) with all source copied to it and the cordova plugins installed into and then build and install it via XCode, the push notifications start working again and the push notification in the XCode debugger looks like this:
{
aps = {
alert = {
body = "This is a message";
title = "Message";
};
};
tap = 0;
}
Should push notification formats differ? Has anyone experienced some similar behavior and how did you solve it?
It seems there was a bug or something in the iOS project. When I removed the ios platform and newly installed it everything started working and it still works until this day.
Also Apple's APS has different push notification object structure than Android's FCM.
In ionic app how can I detect profile modes like vibrate,normal,silent..in both android and ios platform?
I have also tried this..
plugins.ringerMode.getRingerMode(function(ringerMode) {
console.log("The current ringerMode is:" + ringerMode);
});
but not get succeed..
specially for ios devices v.10+ Is there any solution for that?
please help..
I'm working on mobile app through XDK intel, How can I read text file from outside the app?
I tried this code, but it's not working!
function readFile (filepath){
var txtFile = "C:\test.txt";
var file = new File(txtFile);
file.open("r"); // open file with read access
var str = "";
while (!file.eof) {
// read each line of text
str += file.readln() + "\n";
}
file.close();
alert(str);
}
You are building a Cordova app (aka PhoneGap app) when you are creating an app for the Intel XDK. So the rules (and solutions) that apply to Cordova also apply to Intel XDK apps. The XDK is simply providing a way to make it easier to apply and use the standard Cordova tools, it is not providing a different runtime environment (other than including the option to replace the Android webview with a Crosswalk webview).
This describes, at a very high level, what Cordova and Cordova plugins do on an Android device > http://developer.android.com/guide/webapps/webview.html. Similar approaches are taken on iOS and Windows and other platforms supported by Cordova.
As Nicolas stated in his answer, you should use the Cordova File Plugin. On the doc page for that plugin you'll find two references that are worth reading:
http://cordova.apache.org/docs/en/latest/cordova/storage/storage.html
http://www.html5rocks.com/en/tutorials/file/filesystem/
Also, these may be of value:
http://www.html5rocks.com/en/features/storage
http://developer.android.com/training/basics/data-storage/files.html
http://developer.android.com/guide/topics/data/data-storage.html
How to implement Notification API on Electron App?
I tried checking Notification.permission and it returns granted
But when I try to run:
new Notification("FOO", {body:"FOOOOOOOOOOOOOOOOOOOOOOOOO"});
nothing happens. Is it even supported?
A good approach is use node-notifier for notifications, because the package have cross-platform notification support
Note: Since this is an HTML5 API it is only available in the renderer process.
Example :
let myNotification = new Notification('Title', {
body: 'Lorem Ipsum Dolor Sit Amet'
})
myNotification.onclick = () => {
console.log('Notification clicked')
}
Windows
On Windows 10, notifications "just work".
On Windows 8.1 and Windows 8, a shortcut to your app, with a Application User Model ID, must be installed to the Start screen. Note, however, that it does not need to be pinned to the Start screen.
On Windows 7, notifications are not supported. You can however send "balloon notifications" using the Tray API.
Furthermore, the maximum length for the notification body is 250 characters, with the Windows team recommending that notifications should be kept to 200 characters.
More information : https://github.com/electron/electron/blob/master/docs/tutorial/desktop-environment-integration.md#notifications-windows-linux-os-x
The HTML5 Notification API is only available in the renderer process.
You must require the Electron Notification API if you want to use notifications from the main process. The API is different from the standard/HTML5 version.
const {Notification} = require('electron');
new Notification({
title: 'Headline',
body: 'Here write your message'
}).show();
The notification API doesn't work on Windows, because there is no notification API that works on all versions of Windows (really Win10 is the first version where desktops have a documented API for it, Win8.x had it but it was WinRT-only)
Posting an updated answer that Electron has a section in their tutorial for their Notifications and about how to handle Windows
Windows
On Windows 10, a shortcut to your app with an Application User Model ID must be installed to the Start Menu. This can be overkill during development, so adding node_modules\electron\dist\electron.exe to your Start Menu also does the trick. Navigate to the file in Explorer, right-click and 'Pin to Start Menu'. You will then need to add the line app.setAppUserModelId(process.execPath) to your main process to see notifications.
On Windows 8.1 and Windows 8, a shortcut to your app with an Application User Model ID must be installed to the Start screen. Note, however, that it does not need to be pinned to the Start screen.
On Windows 7, notifications work via a custom implementation which visually resembles the native one on newer systems.
Electron attempts to automate the work around the Application User Model ID. When Electron is used together with the installation and update framework Squirrel, shortcuts will automatically be set correctly. Furthermore, Electron will detect that Squirrel was used and will automatically call app.setAppUserModelId() with the correct value. During development, you may have to call app.setAppUserModelId() yourself.
Furthermore, in Windows 8, the maximum length for the notification body is 250 characters, with the Windows team recommending that notifications should be kept to 200 characters. That said, that limitation has been removed in Windows 10, with the Windows team asking developers to be reasonable. Attempting to send gigantic amounts of text to the API (thousands of characters) might result in instability.
for window 7, you might try this: https://github.com/blainesch/electron-notifications - it generates 'desktop' notifications as separate electron windows. It looks pretty slick; I'm about to implement it now. I believe you'll need to use something like https://github.com/electron/electron/blob/master/docs/api/ipc-main.md to communicate between your app and the main electron process which would be responsible for displaying and managing the notifications, unless your main electron process is already responsible for the notification logic.
use
const notification = new window.Notification(
'LO SIENTO OCURRIO EL ERROR:',
{
body: error,
}
);
notification.onclick = () => console.log('Clicked');
notification.onclose = () => console.log('Closed');