I have added a navigator.share function to my react app, but for some reason, it is only sharing the text from the object and not the URL? Is there something I am missing here?
function shareList() {
if (navigator.canShare) {
navigator.share({
title: "Page Title",
text: "brief description",
url: window.location.href,
});
} else {
//functionality for desktop
}
}
<input type="button" value="Share..." onclick="shareList()"/>
On iOS, the share dialogue pops up properly, but the share object is just text and not a URL. Here is a screenshot of the pop-up
Share dialogue screenshot
It appears the issue was with my device. I tested on another device soon after posting and it worked fine, and after restarting my device it worked as intended.
Related
I am probably missing something here but I am trying to click "Allow" for a native popup in iOS11 +. If anyone has any idea on how to determine what the xpath is for this native popup or any other ideas it would save me a lot of headache!
I have tried to switch the correct context, NATIVE_APP I believe, then use an xpath locator click the option but no luck at all.
I think I am on the right track but the xpath just being incorrect.
xpaths I have tried are:
#label="Allow"
//*[. = 'Allow']
//*[contains(text(), 'Allow')]
```browser.contexts(async function (context) {
browser.setContext(context['value'][0]); //switch to native
browser
.useXpath()
.click('#label="Allow"');
}
);```
Error message being,
An error occurred while running .click() command on <#label="Allow">: An element could not be located on the page using the given search parameters.
Update
The below works for iOS11 and iOS12, but is extremely slow for iOS11
browser.contexts(async function (context) {
console.log("this is all the contexts: " + context.value);
browser.setContext(context['value'][0]); //switch to native
browser
.useXpath()
.click('//*[#name="Allow"]’);
}
);
iOS10
browser.execute('mobile:alert', {
notification
action: 'accept',
buttonLabel: 'Allow'
});
I am trying to click "Allow" for a native popup in iOS11
Are you describing a permissions dialog, like a location, contact, or photos permission dialog?
If so, you cannot interact with these from your application. The user must explicitly tap an "Allow" button to grant permissions.
I am trying to setup browser notification for a project I'm working on. The code I have so far is:
// Notification permissions logic handled before...
var notification = new Notification('Title', { body: 'Message' });
notification.onclick = function (e) {
window.focus();
// this.cancel();
};
setTimeout(notification.close.bind(notification), 5000);
The notifications work fine with this code except for one thing. In Chrome clicking on the notification does not set the focus on the browser window. In Firefox this behavior is native out of the box and it works fine without on click handler defined above. I have looked for the solution for this for Chrome and found these:
How to get focus to the tab when a desktop notification is clicked in Firefox?
How to get focus to a Chrome tab which created desktop notification?
However the suggested accepted solutions do not work for me - the event is triggered but the focus is not set.
Does anyone have any suggestions how to make this behave properly?
Chrome version: Version 44.0.2403.130 m
Firefox version: 40.0
It's an hacky solution, but if you registered a service worker you could do something like this.
In the client page:
yourServiceWorkerRegistration.showNotification('Title', {
body: 'Message',
});
In the service worker:
self.addEventListener('notificationclick', event => {
event.notification.close();
event.waitUntil(
clients.matchAll({
type: "window",
})
.then(clientList => {
if (clientList.length) {
clientList[0].focus();
}
})
);
});
Now, my chrome version is 100.0.4896.127. And window.focus() works perfect in onclick of notification callback! It would be helpful to anyone who sees this issue.
I am using Pay With Amazon Express Integration. In that I have to create custom Pay With Amazon button as described here:
Everything is working smoothly, however when I click on Pay With Amazon button, it opens window in same page. I want that window to open in popup.
Is there any way, I can make Pay With Amazon button to open window in popup.
Here is my code:
<script type="text/javascript">
OffAmazonPayments.Button("AmazonPayButton", app.conf.amazonPaySellerId, {
type: "hostedPayment",
hostedParametersProvider: function(done) {
$.getJSON(app.conf.siteUrl + 'generatePaymentRequestSignature', {
amount: $("#depositAmount").val() ? $("#depositAmount").val() : 10,
currencyCode: 'USD',
sellerNote: "Deposit to App",
returnURL : window.location.href,
sellerOrderId : localStorage.getItem("UserAccessToken")
},
function(data) {
if(data.status && data.code == 200) {
done(JSON.parse(data.data));
} else {
alert("Service is not available. Please try again later");
}
})
},
onError: function(errorCode) {
console.log(errorCode.getErrorCode() + " " + errorCode.getErrorMessage());
}
});
</script>
I wanted to open it in popup, because my app will be embedded by other sites using iframe. And when we click on Pay button, it opens in same window which is not functioning.
Note: There is option available for opening window in Popup, for Buttons generated using Button Generator Utility as said here, but don't know how it can be done using hostedPayment type.
Thanks for your time.
There isn't a way to do that currently since it is a hosted solution. The sample you referenced doesn't use the button generator it uses a standard Login with Amazon integration. A button generated with the button generator is considered a Express integration.
The only way to have a popup experience is to do a custom LPA integration but the Pay button will not work in a iframe.
I am developing an app for Android which should have the functionality to take a picture, and share it to the Instagram app.
The app opens up the camera, takes a picture and then the Instagram app is opened with the "Crop photo" window active. It seems to be loading the picture, but after a couple of seconds the app crashes, i can't see that the image ever gets loaded.
I am developing the app on top of Appcelerators Titanium platform, however i do not think that my problem is related to Titanium, but rather how i pass the image.
Since the emulator doesn't have the Instagram app, i am developing on my Galaxy S4. I have tried running logcat through adb to get some sort of error message to help me, but only thing i see is that it notices that Instagram exited.
Here is my code, what could be wrong? I have checked that the image is saved into the filesystem.
Ti.Media.showCamera({
success: function(event) {
var file = Ti.Filesystem.getFile(Ti.Filesystem.tempDirectory,"ggs-instagram.jpg");
file.write(event.media);
var instaIntent = Ti.Android.createIntent({
action: Ti.Android.ACTION_SEND,
packageName: "com.instagram.android",
type: 'image/jpeg'
});
/*instaIntent.putExtra(Ti.Android.EXTRA_TEXT, "EXTRA_TEXT");
instaIntent.putExtra(Ti.Android.EXTRA_SUBJECT, "EXTRA_SUBJECT");*/
instaIntent.putExtra(Ti.Android.EXTRA_STREAM, file.getNativePath());
Ti.Android.currentActivity.startActivity(instaIntent);
},
cancel: function() {},
error: function (error) {
if (error.code == Ti.Media.NO_CAMERA) {
alert("Din telefon/platta har ingen kamera!");
} else {
alert("Kamerafel!");
}
},
mediaTypes: [Ti.Media.MEDIA_TYPE_VIDEO,Ti.Media.MEDIA_TYPE_PHOTO],
showControls: false,
autohide: false,
saveToPhotoGallery: true
});
pls take a look at
Instagram from Android open on certain user and add caption to uploaded image
Instagram Option in Sharing Intent Android
Android: post image and text to Instagram
Normally, when I use in my metro application, the url is opening in the default web browser. I don't want to do this with anchor, I want to do the same behavior via Javascript and as async. But I don't know how to open the url with default browser.
Here is my code:
var $aTag = $("<a/>").click(function (event) {
showYesNoDialog(
"Do you approve?",
"The link will be opened in another window. Do you approve?",
"Yes", // Text of yes button
"No", // Text of no button
function () { // Behavior of yes button
// I tried this but nothing happened.
window.location.href = _URL_; // Should open in chrome or default web browser
},
function () { // Behavior of no button
// do nothing
}
);
});
What I also tried is that:
$("<a href='" + _URL_ + "'></a>").click();
But this didn't work, too.
Finally, I found my answer while searching on google.
Open a URL in a new tab (and not a new window) using JavaScript
I used this code to open the url out the metro app and it worked in my situation:
window.open(_URL_, '_blank');
window.focus();
You cannot launch an actual application from within Metro, but what you can do is launch a file with associated program, and that should give you the functionality you need.
Check Sample
The sample covers files and URI's - http://msdn.microsoft.com/library/windows/apps/Hh701476