iOS
Its the same. The only difference in the case of iOS is the way uuidString
is accessed. The Cordova plugin was written in Objective-C while the Capacitor plugin is Swift. The same value should be returned for both though.
Android
The Android plugins also seems to be referencing the same value, just in different ways. Both pass a content resolver from the app Activity context as the first parameter to Settings.Secure.getString()
. The difference between: this.context.getContentResolver()
and this.cordova.getActivity().getContentResolver()
is how Context is accessed (a big topic on Android development).
Cordova Plugin
From the Cordova plugin guidelines,
getContext() and getActivity() can return the required Context object
Capacitor Plugin
If you go through the code of the Capacitor plugin, the file that is the main entry point calls getContext()
and directly passed it to the Device()
constructor.
In short both refer to the same Activity Context. this.context
is the same as this.cordova.getActivity()
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…