You need to sign in to do that
Don't have an account?
Devid
e.force:navigateToURL not working in android properly
Hi All,
I have created a Lightning component(Aura) and using this salesforce mobile app and I have created a button when the user clicks on that button it redirects the user to square APP.
Here is the Square API doc link:
https://developer.squareup.com/docs/pos-api/web-technical-reference
according to the square doc their different link to redirect on the square app for iOS and Android.
My code works well in iOS but in android, it shows a problem
Here is my code:
component:
controller:
I am not able to understand what I am doing wrong. for iOS this code is working perfectly means successfully redirecting to the square app and doing payment but when I do same things in android it is showing above error.
I also created VF page and added two different link in anchor tag when I tried to open from here its working fine here my site link:
https://devid305001-developer-edition.ap16.force.com/squareTest
and is the VF page code (SquareTest):
I have created a Lightning component(Aura) and using this salesforce mobile app and I have created a button when the user clicks on that button it redirects the user to square APP.
Here is the Square API doc link:
https://developer.squareup.com/docs/pos-api/web-technical-reference
according to the square doc their different link to redirect on the square app for iOS and Android.
My code works well in iOS but in android, it shows a problem
Here is my code:
component:
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" > <lightning:button label="Pay" title="Pay" onclick="{! c.handleClick }"/> </aura:component>
controller:
({ handleClick : function(component, event, helper) { let redirectionLink = ''; if( $A.get("$Browser.isAndroid") ){ redirectionLink = 'intent:#Intent;action=com.squareup.pos.action.CHARGE;package=com.squareup;S.browser_fallback_url=https://www.google.com/;S.com.squareup.pos.WEB_CALLBACK_URI=https://devid305001-developer-edition.ap16.force.com/squareTest;S.com.squareup.pos.CLIENT_ID=sq0idp-v1YAxLJ-mgUnO-rvQmmNIw;S.com.squareup.pos.API_VERSION=v2.0;i.com.squareup.pos.TOTAL_AMOUNT=100;S.com.squareup.pos.CURRENCY_CODE=USD;S.com.squareup.pos.TENDER_TYPES=com.squareup.pos.TENDER_CARD,com.squareup.pos.TENDER_CASH;end'; }else if( $A.get("$Browser.isIOS") ){ redirectionLink = 'square-commerce-v1://payment/create?data=%7B%22amount_money%22%3A%7B%22amount%22%3A%22500%22%2C%22currency_code%22%3A%22USD%22%7D%2C%22callback_url%22%3A%22https%3A%2F%2Fdevid305001-developer-edition.ap16.force.com%2FsquareTest%22%2C%22client_id%22%3A%22sq0idp-v1YAxLJ-mgUnO-rvQmmNIw%22%2C%22version%22%3A%221.3%22%2C%22notes%22%3A%22notes%20for%20the%20transaction%22%2C%22options%22%3A%7B%22supported_tender_types%22%3A%5B%22CREDIT_CARD%22%2C%22CASH%22%2C%22OTHER%22%2C%22SQUARE_GIFT_CARD%22%2C%22CARD_ON_FILE%22%5D%7D%7D'; } let urlEvent = $A.get("e.force:navigateToURL"); urlEvent.setParams({ "url": redirectionLink }); urlEvent.fire(); } })The error in android is here:
I am not able to understand what I am doing wrong. for iOS this code is working perfectly means successfully redirecting to the square app and doing payment but when I do same things in android it is showing above error.
I also created VF page and added two different link in anchor tag when I tried to open from here its working fine here my site link:
https://devid305001-developer-edition.ap16.force.com/squareTest
and is the VF page code (SquareTest):
<apex:page > <a href="intent:#Intent;action=com.squareup.pos.action.CHARGE;package=com.squareup;S.browser_fallback_url=https://www.google.com/;S.com.squareup.pos.WEB_CALLBACK_URI=https://devid305001-developer-edition.ap16.force.com/squareTest;S.com.squareup.pos.CLIENT_ID=sq0idp-v1YAxLJ-mgUnO-rvQmmNIw;S.com.squareup.pos.API_VERSION=v2.0;i.com.squareup.pos.TOTAL_AMOUNT=100;S.com.squareup.pos.CURRENCY_CODE=USD;S.com.squareup.pos.TENDER_TYPES=com.squareup.pos.TENDER_CARD,com.squareup.pos.TENDER_CASH;end"> Click here to open square app in android for payment </a> <br/><br/><br/> <a href="" id="iosLink"> Click here to open square app in iOS for payment </a> <script> var dataParameter = { amount_money: { amount: "500", currency_code: "USD" }, // Replace this value with your application's callback URL callback_url: "https://devid305001-developer-edition.ap16.force.com/squareTest", // Replace this value with your application's ID client_id: "sq0idp-v1YAxLJ-mgUnO-rvQmmNIw", version: "1.3", notes: "notes for the transaction", options: { supported_tender_types: ["CREDIT_CARD","CASH","OTHER","SQUARE_GIFT_CARD","CARD_ON_FILE"] } }; document.getElementById('iosLink').href = "square-commerce-v1://payment/create?data=" + encodeURIComponent(JSON.stringify(dataParameter)); </script> </apex:page>
This seem to be a known and expected behavior on the Android app. Kindly review below link.
https://trailblazer.salesforce.com/issues_view?id=a1p3A000000EArEQAW
Hope above information was helpful.
Please mark as Best Answer so that it can help others in the future.
Thanks,
Vinay Kumar
I tried to check but unfortunately seems like there is no workaround at this time.
Thanks