IOS cordova-sms-plugin issue - ionic-framework

We have a problem with the cordova sms plugin. When you send an sms from ionic v1 app for the first time. Everything works perfect but as soon as you send a second sms the recipient has a comma after it. I'm not sure how this works but now a user will have to manually remove the separator.
var number = 48802;
$cordovaSms.send(number.toString(),message).then(
function (results) {
console.log("SMS sent! ",results);
$ionicLoading.hide();
$scope.job.paymentConfirmed = true;
submit();
},function (e) {
$ionicLoading.hide();
window.localStorage.job = JSON.stringify($scope.job);
$ionicPopup.alert({
title: 'Posting Job Failed',
template: 'Please check your airtime credit if insufficient please top up'
});
console.log("Adding a job error ",e);
}
);

I just tested your code and can see this is not an error with the plugin, this is simply how the messaging app in iOS is designed.
When a number is entered into the recipient list, iOS will automatically put a comma there to allow you to add additional recipients.
The user does not have to manually remove the comment - all they have to do is click in the message textbox and the comma automatically goes away when they start typing their message.
To be clear: I don't think there is much you can do about this, unfortunately :-(

Related

Flutter Firebase Authentication with Email Links not working

I'm following this guide, I'm having this code:
var acs = ActionCodeSettings(
url: 'https://example.com/auth/widget',
androidPackageName: 'com.example',
iOSBundleId: 'com.example',
handleCodeInApp: true,
androidInstallApp: true,
androidMinimumVersion: '12',
);
var emailAuth = 'john.doe#pm.me';
FirebaseAuth.instance
.sendSignInLinkToEmail(
email: emailAuth, actionCodeSettings: acs)
.catchError((onError, stackTrace) {})
.then((value) =>
print('Successfully sent email verification'));
Sending the email works, but when I click on the email, then…
in iOS it opens https://example.com/auth/widget - which is the fallback
in Android it shows a circular loader for about 1s and then it "falls down" and nothing happens
The incoming link handler
FirebaseDynamicLinks.instance.onLink.listen((dynamicLinkData) {
print('got dynamic link! $dynamicLinkData');
}).onError((error) {
print('error error!');
});
I configured dynamic links in Firebase to point to to.example.com. I also added a manual dynamic link to.example.com/test which opens my app (the got dynamic link! message shows up) - so all seems fine, the problem seems to lie in the link generation.
The link structure I get by email is:
https://to.example.com/?link=https://example-abcd.firebaseapp.com/__/auth/action?apiKey…%26continueUrl%3Dhttps://example.com/auth/widget%26lang%3Den&apn=com.example&amv=12&ibi=com.example&ifl=https://example-abcd.firebaseapp.com/__/auth/action?apiKey%3D…%26continueUrl%3Dhttps://example.com/auth/widget%26lang%3Den
After some more painful hours of debugging and reading documentation I finally found it out. Most of this is in the flutter documentation, but since the documentation has broken links and is a bit all over the place it was hard for me to catch it all!
Android
I needed to decrease the androidMinimumVersion from 12 to 1. Then my app opens and I can receive the dynamic link. No idea why. My android simulator is android version 13 but the app never opened.
Before decreasing the android version I also set the sha256 setting in firebase, using gradlew signingReport documented in this answer. Not sure though this was required.
iOS
I forgot to do all the steps documented in receiving links on iOS section, namely:
add the dynamic links domain into associated domains
add FirebaseDynamicLinksCustomDomains into Info.plist
Overall, I found that to get this feature working was really really hard for me as a Flutter beginner. But I guess a lot of the setup I can re-use as the dynamic links capability seems to be something which comes in handy in the future.

Ionic 4 + WhatsApp share - Get receiver / contact details after I share my message

I am using Ionic 4 + SocialSharing-PhoneGap-Plugin.
After I share a message with my contact, how can I get back the contact's name/number and other info back in the promise, so that I can save it in the database?
I have the following code:
import { SocialSharing } from '#ionic-native/social-sharing/ngx';
constructor(private socialSharing: SocialSharing) { }
// Share message via WhatsApp
this.socialSharing.shareViaWhatsApp('Hi', null, null).then(() => {
// How to get the contact's details here, with whom
// I shared my message? Would like to get the name, number
// and all other contact info.
// Following Toast does not seem to trigger
this.toastService.presentToast('Successfully shared coupon on WhatsApp', 'success');
}).catch(() => {
// Sharing via WhatsApp is not possible. How to trigger a toast here as well?
});
How can I show a toast message immediately after return, so that I know that the message was shared successfully? As can be seen from the code, I have a toastService that shows the toast, but it never gets triggered. How can I trigger the toast after successfully sharing my message on WhatsApp, both in success & error cases?
To access contacts, you'll need a separate plugin like Contacts -- maybe get the contact first using that plugin and then use shareViaWhatsAppToPhone to share directly to that number.
The toast should work. From your example, it doesn't look like you've injected the ToastService into the class.

PWA. How to make an offer to the user to install the application?

I can of course force install my pwa on the device. However, existing sites on the market themselves offer the user to install the application. And about the possibility to install my application, the user will not know if he does not want to try (most likely he will not want to).
How to make the user such an offer, I unfortunately have not yet figured out. Articles could not be found (perhaps incorrectly set the search), the analysis of the code of service workers also did not help.
Help please.
On Chrome mobile, the default prompt is very visible. On desktop, less so.
But, Chrome actually has an event for this. If everything is in order for a PWA to be installed, the 'beforeinstallprompt' event is fired. You can simply add a listener to this event, and use that to display a message on your page to inform the user of the possibility to install the PWA.
The following example is written for Angular, but you can get the idea of the event.
ngOnInit() {
/**
* The beforeinstallprompt event is only triggered in certain browsers. This event simply indicates that everything is in order
* for the user to install the PWA. On mobile Chrome, a message is shown by default to the user, but we can also interfere and
* block it. This way, we can show our own message, and continue the event on our own terms.
* In this case, we store the event, and prevent it from continuing. We then show a regular <div> in the HTML, which contains the
* question to install the PWA, and a button to do so. That button then triggers the prompt, which the user can then accept or deny.
* The result of this prompt is mostly irrelevant to the functionality. Our code has no impact on the proceedings of the installation
* after the user has accepted the prompt.
* A possible usecase for the Promise resolved by the prompt, is for metrics. We can use the result to calculate how many users have
* accepted or denied our prompts.
*/
window.addEventListener('beforeinstallprompt', (e) => {
// Prevent Chrome 67 and earlier from automatically showing the prompt
e.preventDefault();
// Stash the event so it can be triggered later.
this.deferredPrompt = e;
console.log('beforeinstallprompt!');
// if askedOnce is true, no need to ask again.
this.showPwaPrompt = !this.askedOnce;
});
}
acceptPwaPrompt() {
this.showPwaPrompt = false;
this.askedOnce = true;
this.deferredPrompt.prompt(); // Wait for the user to respond to the prompt
this.deferredPrompt.userChoice.then((choiceResult) => {
if (choiceResult.outcome === 'accepted') {
console.log('User accepted the A2HS prompt');
} else {
console.log('User dismissed the A2HS prompt');
}
this.deferredPrompt = null;
});
}

Ionic External link from email to application (Deep Linking)

I'm trying to add a link from email
that click on it will open the application in the relevant page.
I haven't found a solution for that yet.
If you do have any recommendation how to do that, i'll be glad to know.
Thanks.
This is the scenario :
user click forgot passowrd.
email is sent via server.
the email contains link for reset the password (this is what i need)
user click on the link an enter the reset password page on mobile application.
It's relevant to say that it should support All ionic platform (most important ios/ android)
I agree with #LiadLivnat in the past I used Custom-URL-scheme.
Here is a snippets of code:
Consider you have some run with reportAppLaunched method:
app.run(function($rootScope){
/* ... */
$rootScope.reportAppLaunched = function(url) {
$log.debug("App Launched Via Custom URL: " + url);
$rootScope.$apply(function() {
if (url.substring(0, 'mailto:'.length) === 'mailto:') {
$rootScope.navigateTo('forgot_password_view', {action: url});
}
});
};
}
Now this global function will be fired when, in my case, user opens contact list and clicks on some member. Android will ask with witch application you want to open this contact and you select . The method handleOpenURL is triggered and you can redirect to specific view in your application.
function handleOpenURL(url) {
var body = document.getElementsByTagName("body")[0];
var rootController = angular.element(body).scope();
rootController.reportAppLaunched(url);
}
Hope it will help,

Opening mailto: links from webview

Just want to start off by saying I'm not a much of a Java dev or anything of an Android dev. The links I've found on SO for solving my issue aren't specific to WL, and I'm not sure where to place the 'solutions' in the build.
I've got simple email link to start this:
In Android (4.0.4) the app will crash saying it's not a supported protocol. That much is expected.
One of the solutions I have (below, from SO, lost the link) seems like the right way to go, but I'm not sure where this is supposed to go.
#Override
public boolean shouldOverrideUrlLoading(WebViewClient view, String url) {
if( url.startsWith("http:") || url.startsWith("https:") ) {
return false;
}
// Otherwise allow the OS to handle it
else if (url.startsWith("tel:")) {
Intent tel = new Intent(Intent.ACTION_DIAL, Uri.parse(url));
startActivity(tel);
return true;
}
else if (url.startsWith("mailto:")) {
String body = "Enter your Question, Enquiry or Feedback below:\n\n";
Intent mail = new Intent(Intent.ACTION_SEND);
mail.setType("application/octet-stream");
mail.putExtra(Intent.EXTRA_EMAIL, new String[]{"email address"});
mail.putExtra(Intent.EXTRA_SUBJECT, "Subject");
mail.putExtra(Intent.EXTRA_TEXT, body);
startActivity(mail);
return true;
}
return true;
}
Any help is obviously greatly appreciated!
In a Worklight hybrid application, you are not required to use native code in order to use features such as mailto:.
To get it working, i.e: to click a link that will open the email screen for the user to fill in the subject and message, you can follow the below. If you need greater functionality, elaborate on it in your question:
Make sure you are using the latest iFix available for the version of Worklight that you are using (due to recently fixed Cordova security bugs that affect this functionality). This can be obtained from either the Eclipse Marketplace or IBM Fix Central.
Follow these steps:
In native\res\xml\config.xml, remove and add the following lines:
- <access origin="*"/>
+ <access origin="mailto://*" launch-external="true" />
In common\index.html I then tried with:
Send email
The result was (depending on your phone setup): either to get an option to set up an email account, select from which account to send the mail to, or get the email compose screen.