I am building a mobile application and want to access the IMEI number.
I have gone through the following plugins.
https://github.com/vliesaputra/DeviceInformationPlugin
https://github.com/hygieiasoft/cordova-plugin-uid
https://github.com/aquto/cordova-plugin-imei
And all of them are giving me 404 error.
Finally I got one plugin that I could install
https://www.npmjs.com/package/imeiplugin
and below is the code I wrote to access the IMEI
The below code is written inside my home constructor.
platform.ready().then(() => {
window["plugins"].imeiplugin.getImei(function (imei) {
console.log(imei);
});
});
But the control never goes to the console.log();
Am I doing anything wrong here??
Or if anyone has integrated the IMEI number with some other method please let me know.
Or as per suggested in the below link do I have to build my own custom plugin??
How to get IMEI number in PhoneGap?
I am stuck here and I am looking for an efficient way any help is appreciated.
Thanks in advance
Actually this plugin works:
https://github.com/hygieiasoft/cordova-plugin-uid
(Using: cordova plugin add org.hygieiasoft.cordova.uid returns 404)
So try this instead:
cordova plugin add https://github.com/hygieiasoft/cordova-plugin-uid
platform.ready().then(() => {
alert(cordova.plugins.uid.IMEI);
});
Related
I'm face such a critical issue in expo google sing-in in app. In the development mode it's work fine but when i'm upload app in test flight it's give URL mis-match error in app.
I'm using expo-google-app-auth library in app. Please anyone help me to overcome this issues.
Thank You in advance.
Stay Safe.
Happy Coding.
Had the same problem. I was trying to solve this for 2 days! I re-read the documentation
https://docs.expo.dev/versions/latest/sdk/google/
and found that I was missing one line of code!
const { type, accessToken, user } = await Google.logInAsync({
iosClientId: <YOUR_IOS_CLIENT_ID_FOR_EXPO>, androidClientId:
<YOUR_ANDROID_CLIENT_ID_FOR_EXPO>, iosStandaloneAppClientId:
<YOUR_IOS_CLIENT_ID>, androidStandaloneAppClientId:
<YOUR_ANDROID_CLIENT_ID>, });
i was missing this:
iosStandaloneAppClientId: <YOUR_IOS_CLIENT_ID>
i only had iosClientId:
I'm trying to use FCM push notifications with my Ionic 2 app via cordova-fcm-plugin.
I've followed every tutorial and it's working fine when i send a push from the firebase console, but i want to do some stuff in my app using its functionalities and the payload, but when i try to use any method from the plugin i get a Cannot find name 'FCMPlugin' error on Visual Studio:
The error
I've been looking for how to use it correctly and haven't found anything, just this question: The Question
So what is the correctly way to implement and use the plugin? Is there a module? I can call it from the 'ionic-native'? I have to import it from somewhere? Just use the plugin .js file link in the index.html? Or this error is commom and in emulation/building it'll work fine?
Thanks :D
PS: I've not tryed to build it or emulate it to see what happens, going to do this now.
EDIT
Ok, so it's an error that won't let me build my app. Rly need to know how to use the plugin now.
You have to declare the FCMPlugin variable after your imports:
import { Foo} from '../pages/foo/foo';
import { Bar } from '../pages/bar/bar';
declare var FCMPlugin: any; // <---- this is the magic line
I'm trying to add the SMS cordova plugin to my ionic application but I'm failing miserably.
I've no idea how to inject the plugin or use it the documentation seems to be more phonegapp orientated.
I've got the following:
Installed
cordova plugin add
https://github.com/cordova-sms/cordova-sms-plugin.git
My view
<button ng-click="send()">Test</button>
My Controller
angular.module('starter.controllers', [])
.controller('DashCtrl', function($scope, $http, $state, $cordovaSms) {
$scope.send = function(){
$cordovaSms
.send('phonenumber', 'SMS content')
.then(function() {
// Success! SMS was sent
}, function(error) {
// An error occurred
});
};
})
I get the following error:
ionic.bundle.js:26794 Error: [$injector:unpr] Unknown provider:
$cordovaSmsProvider <- $cordovaSms <- DashCtrl
I think it's a casing issue. Are you using ionic-native yet? If not, start there.
bower install ionic-native --save
bower uninstall ngCordova --save
Then replace ngCordova with ionic.native in your module dependencies.
Here is working code from one of my projects...
.controller('RosterCtrl', function ($cordovaSMS, ...
// snip ....
$cordovaSMS.send(phone, message)
.then(function () {
$log.log('Message sent.');
});
Google changed the policy regarding to SMS access, so the direct reading of incoming SMS is no longer allowed and the associated permissions will be removed (SMS_READ).
Now, it is necessary to use the Android SMS Retriever API (Android SMS Retriever API) and your SMS message needs to comply a specific format in order to be intercepted by your app.
In Cordova use this plugin to easily read incoming SMS:
cordova plugin add cordova-plugin-android-sms-retriever
Github: https://github.com/diegosiao/cordova-plugin-android-sms-retriever
On IONIC 2 , the cordova-sms-plugin its the solution choose for the native SMS plugin. So far so good, except the case you want to send messages to multiple recipients.
At this moment, cordova-sms-plugin does not send to multiple recipients, even if we use string array. It will successfully send to first recipient, but not to the rest of array.
So after I searched a while I got another cordova plugin, which sends messages to all numbers in array. The only problem is, if among those numbers are invalid or incomplete phone numbers, it simply ignores them and pass to the next number to send.
Would be nice to have a callback or at least a trace, when certain numbers are invalid or incomplete, but at least it sends to multimple numbers.
Cheers
I'm trying to create a little mobile app with ionic and a wordpress (and JSON API) for backend.
I choose cookie auth for log people. This méthode work perfectly in my web browser thanks but when I use "phonegap serve" or apk directly on my phone nothing happen.
According to following lines $cookies.put(...) seems not working on my Android device.
console.log("Cookie: ");
$cookies.put(data['cookie_name'],data['cookie']);
console.log($cookies.getAll());
Have you some idea to resolve my problem ?
Thank you
You can't use cookies, you should use localStorage.
To set the localstorage:
window.localStorage.setItem("key", "value");
To retrieve localstorage:
var value = window.localStorage.getItem("key");
To remove particular localstorage:
window.localStorage.removeItem("key");
To clear all localstorage:
window.localStorage.clear();
For your reference, you can use this link.
I am sure, this will help you.
I want to create an phonegap app using this plugin. I have done this steps to create and add plugin :
1:I am creatin this app using phonegap cli :-
phonegap create GetPhone --id "com.phone" --name "GetPhoneApp"
2: Going into the project and buid
cd GetPhone
phonegap local build android
3:Installing plugin
phonegap local plugin add https://github.com/macdonst/TelephoneNumberPlugin
4:moving telephonenumber.js to www folder
5: adding
<script type="text/javascript" charset="utf-8" src="telephonenumber.js"></script>
into index.html then added below ondeviceready :-
var telephoneNumber = cordova.require("cordova/plugin/telephonenumber");
telephoneNumber.get(function(result) {
alert("result = " + result);
}, function(error) {
alert("error = " + error.code);
});
6: Added
<plugin name="TelephoneNumber" value="com.simonmacdonald.cordova.plugins.TelephoneNumber"/>
into config.xml in www directory.
7: Build
phonegap local build android
8: Uploaded into build.phonegap.com and created .apk file.
Then when i am running this app on android device it does not alert anything. Is there any wrong step i have taken. I dont know much more about phone gap. After googling i have created this. I have seen this tutorial also to add this plugin. When i am build it locally it does not show any error. But it is also not running.
Please help me find the error.
First of all I would suggest you get acquainted with standard tools, especially adb. These will allow you to provide more information, find out what really is going on.
Skimming through the guide is also helpful, so you can be sure you know what you're doing and why you're doing it. Look at step-by-step debugging of Android code as well.
I would also encourage you to build a Cordova application from sources without using the fancy tools to get the hang of what goes where and how all the components come together. Your source tree is confusing and you seem to have used a mixture of Cordova 3.1 and Cordova 2.9, and even Phonegap? You only need to include cordova.js and your script (js/script.js in this case), nothing else at the moment.
Having said that, on to the major issue.
Your call to get returns an error. Why? Take a quick look at the source code of the plugin:
https://github.com/macdonst/TelephoneNumberPlugin/blob/master/src/com/simonmacdonald/cordova/plugins/TelephoneNumber.java
The plugin retrieves the TelephonyManager and tries to call the getLine1Number. And as you can see result != null is false which drops through to returning a PluginResult.Status.ERROR, which is why you get your error alert box.
This is the core issue at hand. TelephonyManager returning a null for your request. Why? After searching around you might stumble on:
Retrieve phone Number in android
TelephonyManager.getLine1Number() failing?
Reading device phone number throws NULLPointerException
So, navigate over to Settings > About Phone > Status on your device and look at the "My phone number" field. Is it "Unknown"? Tough luck then. My SIM doesn't store the number, so I got the same results as you did.
Another thing to note, is that at least on Android 4.4, the method returns an empty string "" instead of a null, so when testing on my Android 2.3.7 device I got a null and thus got the error branch. But on my Android 4.4.2 device I got a "" and got the success branch, but the number was empty, obviously.
You can set the number on the emulator by using this pretty advanced guide if you'd like to try. So what can you do? Probably nothing by using the API, not even the Android system itself can get your number if it's not stored on the SIM card. Asking the user or sending an SMS to discover the number via a web service may be an option as well.
Step number 5 above will not work unless the code is called after the 'deviceready' event is triggered.
you will need some sort of call to know when the document is loaded, you can do either:
<body onload="onLoad()">
<script>
function onLoad() {
document.addEventListener('deviceready', deviceReady, false);
}
</script>
OR (w/ jquery):
<script>
$(document).ready(function () {
document.addEventListener('deviceready', deviceReady, false);
}
</script>
and then create this function:
function deviceReady() {
var telephoneNumber = cordova.require("cordova/plugin/telephonenumber");
telephoneNumber.get(function(result) {
alert("result = " + result);
}, function(error) {
alert("error = " + error.code);
});
}
This will ensure that your document has loaded and that cordova is ready to call to.