I am trying to get my devices UUID so that I can send a notification to a specific device over Firebase using the Device UUID. I have my front end and back end connected so that the back end can send a notification to my front end using Firebase. While trying to get the device UUID, all I get is a 16 character value with numbers and words.
These are my dependencies inside package.json
"dependencies": {
"@angular/animations": "^15.2.0",
"@angular/common": "^15.2.0",
"@angular/compiler": "^15.2.0",
"@angular/core": "^15.2.0",
"@angular/forms": "^15.2.0",
"@angular/platform-browser": "^15.2.0",
"@angular/platform-browser-dynamic": "^15.2.0",
"@angular/router": "^15.2.0",
"@capacitor/android": "^4.1.0",
"@capacitor/core": "^4.1.0",
"@capacitor/device": "^4.1.0",
"@capacitor/ios": "^4.1.0",
"device-uuid": "^1.0.4",
"primeicons": "^6.0.1",
"primeng": "^15.2.0",
"rxjs": "~7.8.0",
"tslib": "^2.3.0",
"zone.js": "~0.12.0"
},
I am using capacitor/device in order to get the UUID.
This is my code that is inside the app.component.ts
where I try to get the device UUID.
import { Component } from '@angular/core';
import { AppService } from './app.service';
import { Device } from '@capacitor/device';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent {
title!: string;
checked: boolean = false;
deviceId: any;
result: any;
platform: any;
info: any;
constructor (private appService: AppService) {}
sendNotification () {
Device.getInfo().then((info) => {
this.info = info
this.platform = info.platform
Device.getId().then((deviceId) => {
this.deviceId = deviceId.uuid
this.result = this.appService.sendNotification(this.platform, this.deviceId);
})
})
}
}
I have a button on the application where when it's clicked it is supposed to show the device UUID and the device info but from this code, all I get from my device is a 16 character value like (9c08a2578a6475d9) which I don't know what this value is.
Can someone help me on how can I get the 36 character UUID from my device?
Also, what is the 16 character value that I am retrieving if is not the device UUID?
I have tried searching on the web and also browsed similar stackoverflow questions like Best possible way to get device Id in Android, how can I get a unique device ID in javascript?, Unique ID of Android device but none of these seem to work for me since I'm using a different approach to this. I have also used both android emulators and physical android devices, but the result is always the same.