Get user call logs in flutter - flutter

I am new to flutter currently i am creating a flutter application where user need to get call history, i have done this in in java(native app) but i have no idea how to do this in flutter . and one more thing how to get run-time permissions for this I have checked documentation of flutter but got nothing related to this.
thank you .

use call_log plugin available in pub.dev
here is the link : https://pub.dev/packages/call_log
the only problem here is that this plugin is only supported in Android.
you can use it like this
Iterable<CallLogEntry> _callLogEntries = <CallLogEntry>[];
_callLogEntries = CallLog.get();
do not forget to add call log permission in menifest file
<uses-permission android:name="android.permission.READ_CALL_LOG" />

Related

Ionic 4 read SMS plugin for OTP Verification

I am developing the ionic4 app, to auto verification or whenever I will get SMS my app has to read that message. for this I used 'Cordova plugin add Cordova-plugin-SMS' but it is not working. i declared 'declare var window: any; and declare var SMS: any;' nothing has worked. it showing "java.lang.ClassNotFoundException: com.rjfun.cordova.sms.SMSPlugin" in Android, in the web while developing it showing " TypeError: Cannot read property 'listSMS' of undefined". can any one help me to solve this issue
There is one plugin which could solve your problem. Named cordova-plugin-sms-receive.
This will help to read sms when any phone received and you can do whatever you want.
https://www.npmjs.com/package/cordova-plugin-sms-receive
That plugin enables sending an SMS from the app, not receiving an SMS.
To get data from an SMS to your app, you could pass it as args using deeplinks. This would required the user to tap a link in the SMS. I am not aware of a way to have SMS data fed to your app automatically, and I would think it is not possible as it would be a security risk.
A custom URL scheme is the simplest way to do that (e.g. mycoolapp://some-path?p1=data1&p2=data2.
App Links (Android > 6.0) and Universal Links (iOS > 9.0) are more powerful but may be unnecessary and are not as well supported. It really depends on your use case.
Ionic has a community maintained plugin for this which I use and does the job, albeit with a workaround needed here and there. Branch.io's plugin is also an option but I haven't used it.
very nice question ... you need to use cordova plugin for that. Below are the
First you need to install Android Permission Ionic Native Plugin.
run these two commands first to install Android Permission Plugin.
ionic cordova plugin add cordova-plugin-android-permissions
npm install #ionic-native/android-permissions
Add android-permissions to your app's Module.
import { AndroidPermissions} from '#ionic-native/android-permissions';
#NgModule({
providers: [
AndroidPermissions
]
})
export class AppModule { }
Check permissions on page
import { AndroidPermissions } from '#ionic-native/android-permissions';
export class HomePage {
constructor(public androidPermissions: AndroidPermissions) { }
ionViewWillEnter()
{
this.androidPermissions.checkPermission(this.androidPermissions.PERMISSION.READ_SMS).then(
success => console.log('Permission granted'),
err => this.androidPermissions.requestPermission(this.androidPermissions.PERMISSION.READ_SMS)
);
this.androidPermissions.requestPermissions([this.androidPermissions.PERMISSION.READ_SMS]);
}
}
After allowing Read SMS permission now you need to install cordova-plugin-sms. Run this command for install it.
ionic cordova plugin add cordova-sms-plugin
npm install #ionic-native/sms
and in your page while reading SMS -
place this in top before declare class
declare var SMS:any;
place below inside class
ionViewDidEnter()
{
this.platform.ready().then((readySource) => {
if(SMS) SMS.startWatch(()=>{
console.log('watching started');
}, Error=>{
console.log('failed to start watching');
});
document.addEventListener('onSMSArrive', (e:any)=>{
var sms = e.data;
console.log(sms);
});
});
}
You can use this Ionic/Cordova plugin for Auto OTP verification and this will not ask the user for SMS read Permissions.
Plugin: https://github.com/hanatharesh2712/ionic-native-sms-retriever-plugin-master
Demo App: https://github.com/hanatharesh2712/sms-plugin-test

Can't use POST method in Ionic 3

I have application that is on App Store.
While developing it, I tested in both Android and iOS.
It works perfectly fine in iOS, right now. However, in Android, I can't login using my RESTful service.
Here is the error visible in remote debug console;
I don't know what does the error trying to tell me? I don't understand why it works in iOS, but not in Android; while it was working past days. I didn't change a thing.
When user hits to Login button, below method is executed;
this.loginService.Login(this.inputName, this.inputPassword).subscribe( () => {
// Route user to home page!
});
The method above is implemented inside login.service.ts. Inside this service, it uses the ApiService class which is defined in api.service.ts
It could be a permission issue. Add these lines in your "platforms/android/AndroidManifest.xml" file and try:
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>

new firebase update: popup window for Google Auth does not show up in Ionic

I recently updated to the new firebase that just came out a few days ago. Since it does not have a Cordova/Ionic special page, I assume that I would need to use the one for Web. I got everything set up, but the signInWithPopup function does not work on actual phone device. It works fine in web browser. I have whitelisted firebase before for the previous version and everything was working just fine for the previous version.Does anyone have any idea? Any help with be appreciated it!
firebase.auth().signInWithPopup(provider).then(function(result) {
// This gives you a Google Access Token. You can use it to access the Google API.
var token = result.credential.accessToken;
// The signed-in user info.
var user = result.user;
// ...
}).catch(function(error) {
// Handle Errors here.
var errorCode = error.code;
var errorMessage = error.message;
// The email of the user's account used.
var email = error.email;
// The firebase.auth.AuthCredential type that was used.
var credential = error.credential;
// ...
});
Here is what's in my content security policy
<meta http-equiv="Content-Security-Policy" content=" img-src &apos;self&apos; data:
http://*.google.com
http://*.gstatic.com
http://*.googleapis.com
http://*.firebaseio.com
https://*.google.com
https://*.gstatic.com
https://*.googleapis.com
https://*.firebaseio.com
Finally I allowed naviagation for everything in my config.xml
<allow-navigation href="*" />
Popup and redirect doesnt work on mobile device. You may need to use cordovaOauth or any other 3rd party to get the access token, and then use signInWithCredential() to authenticate users and get the firebase user data.
Here is a good example:
http://www.clearlyinnovative.com/firebase-3-0-ionic-facebook-login
Currently Firebaseu V3 auth's signInWithPopup/Redirect do not work in cordova apps.
In my Ionic2 RC1 + Firebase3.5 + AngularFire2.beta5 project I had the same problem... Google Auth with Popup worked in Browser but not in my Android .APK
Firstly, I add 192.168.1.172 to my Firebase Console authorized domain list and <allow-navigation href="http://192.168.1.172:8100"/> to my config.xml.
After this, I found that installing Cordova InAppBrowser plugin solves my problem definitively.
I didn't need to modify my code, only plug and play, exactly like David East says in his Social login with Ionic blog.

Phonegap Android Facebook plugin publish_stream permission request throws "Error calling method on NPObject"

I'm using Phonegap for Android and I have just integrated Facebook plugin(https://github.com/phonegap/phonegap-facebook-plugin) to my project. I need to get an AccessToken that could be sent to server so that server could post on user's behalf.
When I at first called FB.login(callback, {scope:'email,user_birthday,user_location'}) everything works fine and dandy. But if I add 'publish_stream' permission to the scope I get an error: "Uncaught Error: Error calling method on NPObject". Error is originating from cordova.js (phonegap 2.8) on line 863 which is:
var messages = nativeApiProvider.get().exec(service, action, callbackId, argsJson);
I initialize the plugin in the next manner:
FB.init({
appId: Global.Facebook.apiKey,
nativeInterface: CDV.FB,
useCachedDialogs: false,
});
If I remove that permission from scope all works ok. Perhaps anyone has some experience or thoughts on how to fix such issue? I debug my app on my phone (Samsung Galaxy S2 connected via USB debugging feature) and for IDE I use adt-bundle's Android Developer Tools (basicly eclipse);
Many thanks in advance.
I seem to have gotten to the root of the problem. When logging in initially, I can't ask for write ("publish") permissions. As I understand I must ask them later after initial login. Which is abit uncomfortable for me, since I might have to prompt user for permissions several times during a single use-case which is bad. Perhaps I am missing some documentation page where all that stuff is already mentioned?
I've founded !!
Go to FacebookSDK Project -> Properties -> Java Build Path -> Order and Export (tab) -> Make sure android-support-v4.jar is checked. Then do a clean and launch...
Great ?
Use this in your session for publish and read permissions (extended permission.)
session.reauthorizeForPublish

BlackBerry Facebook jar file in eclipse

I know this might sound a very basic question but I am having an issue in using Facebook SDK for Blackberry. I have downloaded the latest one 0.8.25. I have imported them in my eclipse and they are present in the referenced libraries. I have a game app where I want the users to login using their facebook account. Which class contains the code for logging in? Are the jar files implementable or they are just for reference? I have read forums posts where users say that they executed Strawberry program but I can no where find any executable source code. Kindly please let me know how do I create a login page for BlackBerry using its SDK. I did go through another link of Sample Code here!
Let me know which class has login code or how do i use the SDK
At the very basic least, you need to get an instance of the Facebook object and call getCurrentUser(). So, for example:
String[] permissions = new String[] { Facebook.Permissions.ALL_PERMISSIONS };
Facebook fb = Facebook.getInstance(new ApplicationSettings(myNextUrl, myAppId, myAppSecret, permissions));
User fbUser = fb.getCurrentUser();
The code in the library will handle all of the details like getting the user to login to facebook account and accept the requested permissions and so on. You'll want to wrap that all in a try/except to catch FacebookException for error conditions (e.g. user refuses your request).