How to get UniqueDeviceID in Ionic 3 without need for a special permission?


#1

I am using the code provided in the documentation to get a unique identifier for the device:

getDeviceUniqueId() {
this.uniqueDeviceID.get()
.then((uuid: string) => this.uniqueDeviceIdStr = uuid)
.catch((error: any) => {
this.uniqueDeviceIdStr = “N/A”;
this.loggingService.logError(“Error getting device unique identifier”, error);
});
}

However, when this code is executed the following message is displayed:

“Allow to make and manage phone calls?”

I am testing against an Android device (version 7) and my application does not require this permission for any other functionality. Removing the code also removes this permission requirement dialog.

The unique identifier is properly displayed if I grant the app the requested permission.

Question: How to get UniqueDeviceID in Ionic 3 without need for a special permission? i need this UniqueDeviceID for pushing notifications, and not uuid which provided in device library.


#2

any suggestions please?


#3

For push notifications you use a push token (or whatever it is called for the push library you are using) - not this kind of identifier.


#4

@Sujan12 , Thanks for your response,
The push works correctly with my current code which is why I just want to solve the permission request issue.
Any ideas?


#5

This is the way how Android works with this king of information. The user will be asked for this permission, unfortunately. What you can do is send a message modal informating that this permission is only to get device id.


#6

https://ionicframework.com/docs/native/unique-device-id/ has nothing to do with Push - so if this plugin is causing unwanted permission popups, remove it and implement your push plugin properly.


#7

@Sujan12 I think he wants the ‘device id’ to send or receive through push… The ‘push’ plugin is only part of code. The question is about the permission information to user, if can prevent it.


#8

Yes. This device ID stuff is not necessary for that. Just use the functionality the push plugin provides.


#9

If you want the uuid of a phone, you can get it with the Device plugin. No permission necessary ( I dont think ).

Like @Sujan12 mentions, it’s not relevant to push, but if you want it for some other reason Device is an / the option


#10

Asks for “manage phone calls” permission. I have made app that gets ID of device, and this permission is required.


#11

Ah. Sorry about that @DanielAccorsi.