How to open all UPI apps installed in phone inside Ionic App - cordova-plugins

I am integrating UPI payment in my Ionic App.
I have injected WebIntent in the constructor of payment.ts and I call method upi() defined in payment.ts on Pay button click in payment.html
upi method defination :
upi(){
const options = {
action : this.webIntent.ACTION_VIEW,
url : 'upi://pay?pa=8400000701#upi&pn=game&tid=cxnkjcnkjdfdvjndkjfvn&tr=4894398cndhcd23&am=10&cu=INR&tn=App Payment'
};
// Open the intent with options
this.webIntent.startActivityForResult(options).then(onSuccess=> {
console.log('Success', onSuccess);
alert('Payment Successfully done.');
},
onError=> {
alert('error');
});
}
I am using Ionic V4 with Cordova and testing the app on my android device.
On pressing Pay button installed UPI apps are not being shown and alert('error') is being executed always.
Please help me with this.

Related

React Native Deep Linking Push Notifications (Using AWS Pinpoint)

I am trying to set up deep linking for my IOS app using push notifications and can not get notifications to direct a user to a specific screen on a physical device (downloaded via TestFlight).
React Native: 0.66.4
React Navigation: v6
Current Situation
Test push notifications through AWS Pinpoint work (they are successfully sent to a device), but will redirect a user to the wrong route (the initial route / home screen) of the application even when using a deep link. The deep link I am passing through AWS Pinpoint is in the form 'appName://ScreenName' (without the quotes).
The deep link to the page I want the user to go to works, but not as a push notification. For example, if I open Notes on my phone and type 'appName://ScreenName' and press the link I will be redirected to the deep link in my app. This convinces me that deep linking is set up properly, maybe I am wrong here?
If I hardcode the url scheme I want to use into my app.js file (running in development on a physical device) I am directed to the proper screen.
It appears that deep linking is working but Linking.getInitialURL() is not returning the url scheme from a push notifications. The url scheme works, but not as a push notification, whether the app is running in the background or not.
App.js
const config = {
screens: {
'ScreenName': "ScreenName",
},
}
const linking = {
prefixes: ['https://appName.com', 'appName://'],
config,
};
const handleOpenUrl = (event) => {
if (event && event.url) {
const route = event.url.replace(/.*?:\/\//g, "")
if (route?.includes("setmpin")) {
let { hostname, path, queryParams } = Linking.parse(route)
const params = path.split("/")[1]
const listener = Linking.addEventListener(
"url",
handleURL(path.split("/")[0], params)
)
}
}
}
useEffect(() => {
Linking.getInitialURL().then((url) => {
const supported = Linking.canOpenURL(url)
if (supported) {
Linking.openURL(url)
}
})
Linking.addEventListener("url", handleOpenUrl);
return () => {
Linking.removeAllListeners("url");
};
}, [])
Questions...
Am I missing anything glaring here, I have read several stackoverflow and similar posts and am not sure what I have missed.
Am I right to believe that deep linking is setup properly since I can test deep links in my Notes app or by hardcoding the url scheme in my App.js file?
Is there a way to validate what url is being passed by Pinpoint? I believe this is what is driving the issue but do not know how I can check this since push notifications only work on my physical device in production.
Thanks! Happy to share any additional information as well...

Cordova iOS app using phonegap-plugin-push not registering or requesting authorization

I have a Cordova (vers 9) app that uses phonegap-plugin-push (v2.3.0) on cordova-ios (v4.5.1) that does not register for notifications when run on an iOS device, (iPad mini iOS 9.3.5). I am using Xcode (vers 8) within MacOSX Sierra. The xcode project Capabilities tab has push notifications turned on, the project builds without error and the App ID configuration has Push Notifications enabled with a valid certificate. Additionally, it does not show as having access to notifications in the settings for the app on the iOS device nor does it prompt for access when run.
How do I narrow down where the registration problem is? Does the device I am running it from have anything to do with it? Am I missing a call that requests access to notification in the code? Am I missing an error routine that might let me know what the problem is?
Actions I have taken:
Uninstalled/reinstalled cordova
Uninstalled/reinstalled ios
Uninstalled/reinstalled phonegap-plugin-push
Changed order they are added
Fixed numerous build errors that prevented the app from building or signing.
Placed app into debugger and stepped through Javascript code where register takes place.
Exported provision profile from release build and examined to ensure entitlement is present.
var app =
{
// Application Constructor
initialize: function ()
{
this.bindEvents();
},
// Bind Event Listeners
//
// Bind any events that are required on startup. Common events are:
// 'load', 'deviceready', 'offline', and 'online'.
bindEvents: function ()
{
console.log( 'mobile-rewards: bindEvents() called' )
document.addEventListener( 'deviceready', this.onDeviceReady, false );
},
// deviceready Event Handler
//
// The scope of 'this' is the event. In order to call the 'receivedEvent'
// function, we must explicitly call 'app.receivedEvent(...);'
onDeviceReady: function ()
{
const push = PushNotification.init(
{
android:
{
},
browser:
{
pushServiceURL: 'http://push.api.phonegap.com/v1/push'
},
ios:
{
alert: "true",
badge: "true",
sound: "true"
},
windows: {}
});
// e.message
push.on('error', function(e)
{
console.log(e.message);
});
push.on('registration', function(deviceInfo)
{
console.log("device info - "+deviceInfo.registrationType+":"+deviceInfo.registrationId);
});
push.on('notification', function(data)
{
console.log(data.message);
});
},
};
// initialize the app.
app.initialize();
I expected the plugin to register successfully but it doesn't appear to have done so. There is no error present coming from the error handler and the plugin appears to function normally. The debug output log from the plugin shows progress through the entire PushPlugin.m code for the init. The exported app shows the aps-environment provision within it for production. However, the application neither returns a registration ID, prompts for notification access, nor shows up as even needing these privileges in the settings.

Phonegap Build cordova-plugin-facebook4 plugin not working on iOS

I am creating a phonegap build app which contains a facebook login.
Below are some details.
- The app has a Login with facebook button
It uses cordova-plugin-facebook4 plugin (https://www.npmjs.com/package/cordova-plugin-facebook4)
The integration code is below:
facebookConnectPlugin.login( ["public_profile"],
function ( userData ) {
alert( "login" );
//fetch user info using graph api
facebookConnectPlugin.api( "me/?fields=id,name,email,gender", ["email", "public_profile"],
function ( result ) {
alert( "login success" );
//store access token in local storage
facebookConnectPlugin.getAccessToken( function ( token ) {
console.log( "Token: " + token );
} );
},
function ( error ) {
alert( "Failed: " + error );
} );
}, function ( error ) { alert( "error" ); }
);
The above code works fine for on the android app.
- The above code does not work in iOS app
Device used for testing: IPad mini iOS version 10.x.
On developer.facebook.com, the app settings for iOS platform are as follows:
Bundle ID: same value as widget id in config.xml for phonegap
iPhone store id: empty
url scheme suffix: empty
ipad store id: empty
Single Sign On toggle: YES
Below is the current behavior for iOS iPad:
1. User clicks on Login using Facebook in the iOS app
2. User is taken to facebook permissions page in safari browser
3. User enters user id and password
4. User is asked for permission and User clicks "Confirm"
5. Safari shows a popup asking "Open in App?"
6. User clicks Open
7. User is taken to the same app and the same page and displayed the same login link.
Note that the control is not passed back to continue the script at all, its almost that the app was relaunched from start.
Safari web inspector does not show any errors.
GapDebug on mac (i am using a virtualbox Yosemite mac version) does not show any errors.
Please help as I am not very sure at this point, what else I am missing.
I know its late to answer for this question but it might help other to fix this issue. So here is the solution
<meta http-equiv="Content-Security-Policy" content="default-src * gap://ready; style-src 'self' 'unsafe-inline'; img-src 'self' data:; script-src * 'unsafe-inline' 'unsafe-eval'">
add this in index.html. gap://ready is required for iOS 10

Twitter crashes after Tweet

I'm using:
window.open(`twitter://post?text=${caption}`, "_system");
to post tweets from my Ionic 2 app.
This successfully opens the app and creates the tweet.
After the post the twitter just crashes and my app crashes too.
I could get this log from Android Studio:
https://www.dropbox.com/s/o1d9cr6htug4ai6/Screenshot%202017-01-26%2018.05.09.png?dl=0
This happens both with Android and iOS phones.
Anyone has seen this issue?
Thanks
Why not use InAppBrowser ?
import {InAppBrowser} from 'ionic-native';
...
let browser = new InAppBrowser('https://ionic.io', '_system');
But the better solution you want is ionic built in social sharing plugin
import { SocialSharing } from 'ionic-native';
// Check if sharing via email is supported
SocialSharing.canShareViaEmail().then(() => {
// Sharing via email is possible
}).catch(() => {
// Sharing via email is not possible
});
// Share via email
SocialSharing.shareViaTwitter(message, image, url).then(() => {
// Success!
}).catch(() => {
// Error!
});

How to make a "Rate this app" link in React Native app?

How to properly link a user to reviews page at App Store app in React Native application on iOS?
Use Linking to open up the url to the app store. To construct the proper url, follow the instructions for iOS and/or android. E.g.
Linking.openURL('market://details?id=myandroidappid')
or
Linking.openURL('itms-apps://itunes.apple.com/us/app/apple-store/myiosappid?mt=8')
For iOS you Have to add LSApplicationQueriesSchemes as Array param to Info.plist and add items to it.
For example to AppStore linking I use itms-apps as one of params in this array.
For example:
<key>LSApplicationQueriesSchemes</key>
<array>
<string>itms-apps</string>
</array>
Your link should be like this
itms-apps://itunes.apple.com/us/app/id${APP_STORE_LINK_ID}?mt=8.
Well. Now you have all stuff to do Link component with method
handleClick () {
Linking.canOpenURL(link).then(supported => {
supported && Linking.openURL(link);
}, (err) => console.log(err));
}
This is something similar, it shows an alert box to update the app and it opens the play store or the app store depending on their device os.
function updateAppNotice(){
const APP_STORE_LINK = 'itms://itunes.apple.com/us/app/apple-store/myiosappid?mt=8';
const PLAY_STORE_LINK = 'market://details?id=myandroidappid';
Alert.alert(
'Update Available',
'This version of the app is outdated. Please update app from the '+(Platform.OS =='ios' ? 'app store' : 'play store')+'.',
[
{text: 'Update Now', onPress: () => {
if(Platform.OS =='ios'){
Linking.openURL(APP_STORE_LINK).catch(err => console.error('An error occurred', err));
}
else{
Linking.openURL(PLAY_STORE_LINK).catch(err => console.error('An error occurred', err));
}
}},
]
);
}
I am using this library. seems pretty good. You just have to specify the package name and App store ID and call the function. And it's cross-platform too.
render() {
return (
<View>
<Button title="Rate App" onPress={()=>{
let options = {
AppleAppID:"2193813192",
GooglePackageName:"com.mywebsite.myapp",
AmazonPackageName:"com.mywebsite.myapp",
OtherAndroidURL:"http://www.randomappstore.com/app/47172391",
preferredAndroidMarket: AndroidMarket.Google,
preferInApp:false,
openAppStoreIfInAppFails:true,
fallbackPlatformURL:"http://www.mywebsite.com/myapp.html",
}
Rate.rate(options, (success)=>{
if (success) {
// this technically only tells us if the user successfully went to the Review Page. Whether they actually did anything, we do not know.
this.setState({rated:true})
}
})
} />
</View>
)
}
2021 Update:
Some of the other answers are quite old, and don't support using the in-app review API added in iOS 10.3 (SKStoreReviewController) and Android 5 (ReviewManager). If you're adding reviews to your React Native app in 2021 you should ideally use these if they are available.
Expo provide a library, https://docs.expo.io/versions/latest/sdk/storereview/ , which will use these newer APIs if they are supported on the user's device, and falls back to opening the store page if not.
There is also https://github.com/KjellConnelly/react-native-rate which has similar functionality, but with a lot more configuration options. E.g. you can decide whether or not to use the in-app API some or all of the time (which might be a good idea, as the in-app API has a lot less friction for the user but you can only ask a few times a year).
Using third party libraries, in ios it is opening itunes, let me tell you the exact way for opening appstore.
First thing your should be live and it'll work on physical device(simulator is not guaranteed)
const url = Platform.OS === 'android' ?
'https://play.google.com/store/apps/details?id=YOUR_APP_ID' : 'https://apps.apple.com/us/app/doorhub-driver/id_YOUR_APP_ID'
Linking.openURL(url)
You can find your ios link by searching your app on appstore and copy that url.

Resources