Is it safe to use document.body in an Ionic app? - ionic-framework

I have no chance to test on an Android/IOS device right now. Is it safe to use
document.body.addEventListener('click', function (e) {})
in an Ionic app? Will it work on mobile device etc.?
(I am new to hybrid apps, sorry if it's a silly question)

I have used event listener once in my ionic app. But I observed that when you attach event listener in one page its get attached to the whole application. So, whenever you click anywhere in the app, the event gets invoked.
Its not a best practice to use document methods in ionic app. It can produce other errors. Try to use inbuilt native ionic features.

First, why you need to add click event to Body. Because this will get trigger a click event when user taps anywhere in the screen. ITs not good practice. Instead if you want to handle click event to a particular Screen. You can handle it in the corresponding component template files.

Related

Is there any way to have a same changes runtime on different devices?

I'm starting with Flutter and have a question. I want to make an app where you click a button and score increases(I know how to this) but I want it on several devices at once. So when you click another phones see the result right now? How can I implement it?
this could be done with a server, the simplest option would to use Firebase Firestore, here is a complete article on how to do it: https://heartbeat.fritz.ai/using-firebases-cloud-firestore-in-flutter-79a79ec5303a
Firestore is realtime (you can "subscribe" to it and get notified when something has changed.

Is it possible to activate ionic app on call

I am not sure it is possible in ionic or not. What i want to do is create an app that can record user calls. so app must be activate when user make or get a call.
can anyone tell me if it is possible, how to do this?
Beware this won't be an easy task but "never give up, never surrender". You'll want to use a variation of techniques first off this isn't an Ionic thing as much as it is a PhoneGap thing - ionic runs on phonegap.
Your workflow will look something like this:
User opens your app sees a list of contacts
(the formatted names of contacts are different for android & ios so be prepared to test for this.
http://ngcordova.com/docs/plugins/contacts/)
Contacts are displayed in ion-list user select one and phone's dialer launches (use href=tel:xxxxx)
From there you're going to want to trigger the audio capture plugin's API
https://github.com/apache/cordova-plugin-media-capture
To add the plugin to your project:
cordova plugin add cordova-plugin-media-capture
While it doesn't directly say it can record in call conversations it should still work.
It can definitely be done the storage space is also of concern, you'll have to set something in place to tell the user how many seconds/minutes they have the capacity to store.
That should get you started there will certainly be unforeseen nuances.
Good luck.
We can record calls with cordova-media-plugin plugin in android.
First install the media Plugin by executing the following command
cordova plugin add cordova-plugin-media
Then goto the Plugin folder and traverse into the following file “plugins\cordova-plugin-media\src\android\AudioPlayer.java” . Here in the startRecording function we have line
this.recorder.setAudioSource(MediaRecorder.AudioSource.MIC); line number is 154
Change it to this.recorder.setAudioSource(MediaRecorder.AudioSource.VOICE_CALL);
We can replace MIC with any audio source in the following link. for example VOICE_COMMUNICATION,VOICE_DOWNLINK,VOICE_RECOGNITION etc
https://developer.android.com/reference/android/media/MediaRecorder.AudioSource.html

How do you add a pulldown to refresh feature on a Apple Watch using Swift

Is it possible on a WKInterfaceController to know when a WKInterfaceTable has been pulled down so I can refresh the contents of the table? I know this is possible on many iphone apps and im looking for a similar feature.
If so, could you please provide some example code?
This is not possible in the WatchKit SDK. There is no access to anything similar to the UIRefreshControl from iOS for third party developers, and additionally nothing equivalent to UIGestureRecognisers nor API functions associated with taps or swiping for third party developers.
With regards to taps, it is possible to respond to events on button presses, through an IBAction, it's just that we can't interrogate the taps in terms of things like tap location...

iPhone. Open application during call

Is there any way to do this?
In other words, is it possible during a call to allow the user to open a certain application? (for example, to provide information based on the person who is calling).
If not, will something like this be available on iOS 4?
You can open an application during a call (not automatically).
User can press the home button (the one that is under the screen) during a call and open some third party application.
Another issue is to retrieve the contact that the user is talking to now - I believe that this is impossible.
Regarding iOS 4 - I am pretty sure that this will be possible...
No.
AFAIK, there are two ways to launch an application:
The user taps the icon
The user responds to a push notification
You cannot directly control when your app is launched. Furthermore, once your app is running, there is no way to access information about the current call.

Opening one app from another app without closing the app

In the home page of my iphone app, there is a button added. When that button is clicked some other iphone app needs to be opened in a new viewcontroller (with out closing the parent app).There will be a back button on this view controller. When the back button is clicked, the new viewcontroller which is showing the another app needs to be closed and our parent app's home page needs to be shown.
Please give me some ideas on how to do this. I googled for this i didnt get any solutions.
Thanks,
Raja.
-- the following applies to iOS versions previous than 4.0 :)
Actually, there can be only one iPhone application running at once (with exceptions of Safari, Phone and some other system applications). The iPhone Human Interface Guidelines say so:
Only one iPhone application can run at a time, and third-party applications never run in the background. This means that when users switch to another application, answer the phone, or check their email, the application they were using quits.
However, if you only need to e.g. show a webpage, you can do it using UIWebView
Also, if you need to open another application, you should use URLs as pointed by Steve Harrison. This will, however, close your application. The recommended behavior in this case is to remember your application state and restore it when the application is run again, as Nithin writes.
According to apples documentation, they are not allowing any applications to be run in the background, except system generated ones. So you will be unable to do the thing you are going to implement. However, there is one thing that can make the same result.
You told that you are calling other application to run on a button click. Before initiating that application, save the current state of your application, may be using sqlite3 or core-data, and then open the other one. While returning back, load the pre-saved data from the database or wherever you have stored it. Every time you start the application, you check for the persisted data, if exists, load it or otherwise load your basic view
I don't think that you can run other iPhone apps within your own one. It doesn't make sense. You can open another iPhone app via a URL (see here and here), but this will close your app.
Like it has been stated: running two apps is not allowed by apple. You can however implement this apps features into you're app and have both get and save data to the same server...
Or like Nithin said: this functionality is available on JB iphones. Look into "backgrounder" for implementing one solution for normal users and one for thouse that has jailbroken.