How can I share text on a Windows 10 App? - windows-phone

I am building a Windows 10 Web App by Project Westminster. I want to create a button to invoke the native share capability, sharing some text I have. I have the below codes. Clicking on my button would call the share() function.
function share() {
Windows.ApplicationModel.DataTransfer.DataTransferManager.showShareUI();
}
function shareTextHandler(e) {
var request = e.request;
request.data.properties.title = "Share Text Example";
request.data.properties.description = "Demonstrates how to share.";
request.data.setText("Hello World!");
}
app.onactivated = function (args) {
if (args.detail.kind === activation.ActivationKind.launch) {
if (args.detail.previousExecutionState !== activation.ApplicationExecutionState.terminated) {
// This app is newly launched. Register the app as share source.
var dataTransferManager = Windows.ApplicationModel.DataTransfer.DataTransferManager.getForCurrentView();
dataTransferManager.addEventListener("datarequested", shareTextHandler);
} else {
// TODO: This app was reactivated from suspension.
// Restore the app state here.
}
args.setPromise(WinJS.UI.processAll());
}
};
But now when I click on the button, it will share the screen captured on my app, not the text I intended to share. How can I correct the behaviour? Thanks!

Related

I am trying to login to the application but it says "A native alert dialog was invoked on page", I tried manually and could not see any dialog box

I am new to test cafe. I am trying to login to the application but it says " A native alert dialog was invoked on page, but no handler was set for it. Use the "setNativeDialogHandler" function to introduce a handler function for native dialogs.", I tried manually and could not see any dialog box.
page and function to login
import { Selector } from 'testcafe';
class Page {
constructor () {
this.loginInput = Selector("input[name*='username']");
this.passwordInput = Selector("input[name*='password']");
this.submitButton = Selector("div[role=button] div[class='gw-label']");
}
async login (t) {
await t
.maximizeWindow()
.typeText(this.loginInput, 'testRole')
.typeText(this.passwordInput, 'P#ssw0rd')
.setNativeDialogHandler(() => true)
.click(this.submitButton);
await t.wait(2000)
.expect(Selector("div[class = 'gw-TitleBar--title']").innerText).contains('Dashboard');
}
}
export default new Page();
Test:
website backend code:
enter code here

How do i get a user to open my react native app from a text message (basically i need to make share profile in my react native app)

## import ##
import {Share, Button } from 'react-native'
Function to share. This function need to have link to a page of this app which will be sent to another user, who can see the same page if the app is installed, and if it's not, then it must be redirected to play store.
const onShare = async () => {
try {
const result = await Share.share({
message:
'React Native | A framework for building native apps using React https://play.google.com/store/apps/details?id=com.test',
});
if (result.action === Share.sharedAction) {
if (result.activityType) {
// shared with activity type of result.activityType
} else {
// shared
}
} else if (result.action === Share.dismissedAction) {
// dismissed
}
} catch (error) {
alert(error.message);
}
};
button:
<Button onPress={onShare} title="Share" />
To add a feature to open the app from the link then we should have to implement the firebase dynamic-link library and use it in our app navigation to check whether we have received the link in our app then we have to set the initial route to open a specific screen otherwise fallback to play store link if app not installed the fallback will auto handled by the dynamic-link library.
checkout the doc.
https://rnfirebase.io/dynamic-links/usage

show modal when network is offline in ionic 4

I want to display a modal when the network connection is offline.
i have this working function that says to me when the network is online or offline:
verifyNetworkConnection() {
this.networkService.isNetworkConnected
.pipe(distinctUntilChanged())
.subscribe(connected => {
if (connected) {
console.log('Online!');
} else {
console.log('Offline!');
this.screenService.createModal(LostConnectionComponent);
}
});
}
when the conncetion is offline, i want to display a modal, but i got this error in my console:
GET http://localhost:8100/0.js net::ERR_INTERNET_DISCONNECTED
GET http://localhost:8100/164.js net::ERR_INTERNET_DISCONNECTED
why i cant open a modal when its offline?
this is my create modal function:
public async createModal(component, componentProps?) {
const modal = await this.modalCtrl.create({
component,
componentProps
});
return await modal.present();
}

I have created a chat application in which every ten second it takes records from database but i want to show notification at taskbar

I want to show new message notification at taskbar in asp.net MVC or in somewhere to aware user that new message have came.
You can add one Boolean column in you table namely "Seen" with default false value. when user open that message then update that value as true. so you will be easily able get not seen messages for notification. and you can show notification at the top of the page in header section.
We can show desktop notification by javascript function
function createNotification() {
var options = {
body: 'This is the body of the notification',
icon: 'stupidcodes.com.png',
dir: 'ltr'
};
var notification = new Notification("Hi there", options);
notification.onclick = function () {
window.open(document.URL);
};
}
function notifyMe() {
if (!("Notification" in window)) {
alert("This browser does not support desktop notification");
}
else if (Notification.permission === "granted") {
createNotification();
}
else if (Notification.permission !== 'denied') {
Notification.requestPermission(function (permission) {
if (!('permission' in Notification)) {
Notification.permission = permission;
}
if (permission === 'granted') {
createNotification();
}
});
}
}
first check throgh ajax function if there is any unread funtion then call this notifyMe() function

Ionic 2 show login page over slide menu app

Q) How to I show a login page over the top of my standard slide menu app in Ionic 2?
My slide menu app is up and running, I just need that initial login page setup correctly.
Things I know:
How to show a modal page with nav.present().
How to dismiss a modal page.
Things I DON'T know:
Where to instantiate + show this page
How to have it accessible from any current page (i.e. if the user is logged out)
Note: this is for Ionic 2, not 1. I know there are many examples of this in Ionic 1, but they're not applicable thanks.
Any ideas? Thanks.
Solved: Using event listeners as follows:
1.) I have added a LoginPage to my app.ts:
import {Events} from 'ionic-framework/ionic';
import {LoginPage} from './pages/login/login';
Then, I made it the rootPage:
class MyApp {
rootPage: Type = LoginPage;
2.) Then, I register some listeners:
ngOnInit() {
this.subscribeToEvents();
}
ngOnDestroy() {
this.unsubscribeToEvents();
}
subscribeToEvents() {
this._events.subscribe('login:success', () => {
this.getNav().setRoot(TodosPage);
});
this._events.subscribe('logout:success', () => {
this.getNav().setRoot(LoginPage);
});
}
unsubscribeToEvents() {
this._events.unsubscribe('login:success', null);
this._events.unsubscribe('logout:success', null);
}
getNav() {
return this.app.getComponent('nav');
}
3.) Then, in my LoginPage:
<button full (click)="login()">Login</button>
login() {
// Do some auth here first...
this._events.publish("login:success", null);
}