How to choose dialer app in iOS Ionic app? - ios

I am currently working on an ionic app for iOS and I am facing a problem.
I want to make a call via a SIP client. The thing is iOS doesn't let me choose which app to use for the call, it just uses the native dialer.
My question is: is there any way to make iOS ask me which app to choose?
The code I currently use is:
window.open('tel:' + nr);
I also tried:
window.open('tel:' + nr, '_system');

You can use Call Number native plugin.
Installation :
ionic cordova plugin add call-number
npm install #ionic-native/call-number
Usage :
import { CallNumber } from '#ionic-native/call-number/ngx';
constructor(private callNumber: CallNumber) { }
...
this.callNumber.callNumber("18001010101", false) // Set to false to allow user to choose app
.then(res => console.log('Launched dialer!', res))
.catch(err => console.log('Error launching dialer', err));
callNumber() takes two parameters :
number: String; phone number to call (e.g. "1234567890")
bypassAppChooser: boolean; true if you always wish to bypass the app chooser if user has multiple applications installed that can handle calls

Related

ionic cordova speech recognition plugin works well on android but fails on ios

I have created ionic app and used cordova-plugin-speechrecognition for speech to text conversion.
The Code used in the apps is as follows:
initSpeech() {
this.speechRecognition.hasPermission()
.then((hasPermission: boolean) => {
console.log(hasPermission)
if (!hasPermission) {
this.speechRecognition.requestPermission()
.then(
() => console.log('granted'),
() => console.log('Denied')
)
}
})
}
start() {
// Start the recognition process
this.speechRecognition.startListening()
.subscribe(
(matches: Array<string>) => { this.voicetext = matches[0]; this.mainForm.controls['comments'].setValue(matches[0]); },
(onerror) => console.log('error:', onerror)
)
}
//stop listening for(ios only)
stop() {
this.speechRecognition.stopListening();
}
This code runs well on android where the google speech Api gets called.
When I ran it on iOS , I made the required changes like adding
NSSpeechRecognitionUsageDescription permission in info.plist of ios .
Not sure but speech recognition doesn't work on ios 13.3 when I am testing it through the apple developer account test flight app.
Thanks in advance
Sorry, "speechRecognition" only works on the web. I tried to run it on mobile for 2-3 days, but it didn't work.

Not able to access ionic plugin keychain key value pair in iOS from share extension code.

I have created an hybrid app where we upload files using ionic.
For iOS we created a share extension to upload the file and right now trying to pass credentials from ionic application to shared extension in iOS.
I used iOS keychain mechanism as it is supported by ionic native and iOS both.
Share extension I have written in swift and key chain implementation here is using a wrapper like ionic plugin in ionic application.
I am able to save information in ionic plugin and fetch in ionic itself.
Similar is the case with shared extension.
although I am not able to get the information which is been shared to shared extension from ionic.
this is what i am using in view controller in shared extension.
let keychainWrapper = KeychainWrapper.init(serviceName: "xxxx.xxx.xxx" )
let str = keychainWrapper.accessGroup
let keyBool = keychainWrapper.accessibilityOfKey("key")
let value = keychainWrapper.string(forKey: "key", withAccessibility:KeychainItemAccessibility.whenPasscodeSetThisDeviceOnly)
let serviceName = keychainWrapper.serviceName
in ionic :
this.keychain.set(key, value,false).then(() => {
this.keychain.get(key)
.then(value => console.log('Got value', value))
.catch(err => console.error('Error getting', err));
})
.catch(err => console.error('Error setting', err));
Is there any other way share information like NSUserdefaults etc which is supported by ionic and iOS swift both?
This tutorial is what I have been following.
In ionic I had to use app preferences plugin. this gave me access to the user defaults although to fetch the group had to change the ionic plugin code so that I could share user defaults saved in ionic and fetch the same thing in app extension.
Plugin
https://ionicframework.com/docs/native/app-preferences/
//ionic code
let dict12 = this.appPref.suite('group.xxxxxxx')
this.appPref.store('group.pmshare', 'keyNa', 'valueNa')
console.log('dict: ' + dict12)
this.appPref.fetch('group.pmshare', 'keyNa').then(str => {
console.log('str: ' + str)
})
// shared extension code
var defaults = UserDefaults.init(suiteName: "group.xxxxxxx")
print(defaults?.string(forKey: "keyNa"))
defaults?.set("fromExtValue", forKey: "fromExt")
Always remember to create a group under target->app groups->ON
Same group will be used to share data between both the applications.
This can be actually used for Inter Application Communication in iOS. When the app is developed using Ionic.

how to take screenshot of IOS phone using react-native

Is it possible to programmatically take a screenshot of the current phone view while the react-native app is in the background? The expo api for takeSnapshotAsync requires a view ref to work. I do not want to capture the actual app itself. I want to capture whatever the user is doing on their phone.
I believe this one should be able to do what you want: https://github.com/gre/react-native-view-shot
import RNViewShot from "react-native-view-shot";
RNViewShot.takeSnapshot(viewRef, {
format: "jpeg",
quality: 0.8
})
.then(
uri => console.log("Image saved to", uri),
error => console.error("Oops, snapshot failed", error)
);
Try to call RNViewShot in setInterval maybe it will work even when the app is minimalized. If RNViewShot will not work then you will have to create your own native ios module.

Ionic 2 Camera select Video on iOS not working

I'm developing a App with Ionic 2 and I'm have problems with #ionic-native/Camera. I've this code on Upload.ts
let loader = this.loading.create({
content: 'Carregando video....'
});
loader.present().then(() => {
const options: CameraOptions = {
quality: 100,
destinationType: this.camera.DestinationType.FILE_URI,
sourceType: this.camera.PictureSourceType.PHOTOLIBRARY,
mediaType: this.camera.MediaType.VIDEO,
}
this.camera.getPicture(options).then((videoData) => {
this.uploadForm.controls['file'].setValue(videoData)
loader.dismiss();
}, (err) => {
console.log(err);
});
});
This code works fine in Android, but when I run ionic cordova run ios -lc, the promise this.camera.getPicture(options) is never resolved, so the loader keep running forever.
Thanks in advance!
So, I found the problem. First thing is that native components bugs with -l (--livereload). I don't know how to explain why but I got this information from the Ionic Worldwide slack. A member from Ionic Team said:
"live-reload on a device can cause issues with plugins and file system".
So I used this video to understand how to debbug the APP using the iOS emulator and Safari.
https://www.youtube.com/watch?v=Aob749bkoLY
A little brief of the video: when using iOS emulator, you can access the menu Developer > Emulator > <App Name>. A new window with inspector tools will open and logs from the emulator will appear on this window.
I found out that's the video url was incorrect. Before, to be compatible with Android, I've this code responsible to find the video pointer in system and send to the server:
filePath = 'file:///' + this.uploadForm.controls['file'].value;
But, iOS File Picker already has a "file:///" prefix. So prefixing it again made it wrong. So I updated the code to be like this:
if (this.platform.is('android')) {
filePath = 'file:///' + this.uploadForm.controls['file'].value;
} else {
filePath = this.uploadForm.controls['file'].value;
}
This resolved the problem.

PushPlugin Not Asking for Permissions on iOS

I'm working on setting up Push Notifications for an iOS app using the Ionic Framework but I'm running into a problem.
I added the plugin using the following
ionic plugin add https://github.com/phonegap-build/PushPlugin.git
and then added the following to my services.js file:
window.onNotificationAPN = function(event){
alert(event);
}
angular.module('starter.services', [])
.run(function($ionicPlatform){
$ionicPlatform.ready(function($scope, $window){
var tokenHandler = function(result){
alert('tokenHandler' + result);
}
var errorHandler = function(error){
alert('errohandler' + error);
}
var pushNot = window.plugins.pushNotification;
pushNot.register(
tokenHandler,
errorHandler,
{
"badge":"true",
"sound":"true",
"alert":"true",
"ecb":"onNotificationAPN"
}
);
});
})
When I run the app on my test device (running iOS 6.1.6) using command+R or sending it using testflight the application runs but never asks for permission to send push notifications and the the tokenHandler function is never called. Any help would be greatly appreciated.
Thanks for asking the question. I was searching for this for hours.
Turns out the solution for me was making sure that the opening angular module line in the app.js file included the ionic.service.core module dependency.
Then everything worked.
NOTE: (i wish it had thrown an error instead of allowing the push.register call to actually return a token)
angular.module('starter', ['ionic', 'ionic.service.core'])
The way I was able to solve this was to switch over to using ngCordova's Push script with the PushPlugin.

Resources