From e4545f597c01bb23674e2f1e95c9080f6ae43e82 Mon Sep 17 00:00:00 2001 From: Richard Date: Tue, 12 Sep 2017 13:54:36 +0800 Subject: [PATCH 1/6] add android support --- index.android.js | 5 +++++ index.d.ts | 4 ++++ package.json | 18 ++++++++---------- 3 files changed, 17 insertions(+), 10 deletions(-) create mode 100644 index.android.js create mode 100644 index.d.ts diff --git a/index.android.js b/index.android.js new file mode 100644 index 0000000..1754c7f --- /dev/null +++ b/index.android.js @@ -0,0 +1,5 @@ +var device = require('platform'); + +function getUUID() { + return device ? device.uuid : ""; +} \ No newline at end of file diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..9d78f0a --- /dev/null +++ b/index.d.ts @@ -0,0 +1,4 @@ + + + +export function getUUID(): string; \ No newline at end of file diff --git a/package.json b/package.json index 8e7ac0a..43a2f34 100644 --- a/package.json +++ b/package.json @@ -1,26 +1,24 @@ { - "name": "nativescript-ios-uuid", + "name": "nativescript-uuid", "version": "0.0.1", - "description": "A NativeScript plugin for iOS that allows you to get a UUID (Universal Unique Identifier) for a device.", + "description": "A NativeScript plugin that allows you to get a UUID (Universal Unique Identifier) for a device.", "main": "index.js", + "type": "index.d.ts", "nativescript": { - "id": "org.nativescript.iosuuid", + "id": "org.nativescript.uuid", "platforms": { - "ios": "1.3.0" + "ios": "1.3.0", + "android": "1.3.0" } }, "repository": { "type": "git", - "url": "https://github.com/hamorphis/nativescript-ios-uuid.git" + "url": "https://github.com/gdtdpt/nativescript-uuid.git" }, "keywords": [ "NativeScript", - "iOS", "UUID", "Device" ], - "author": "Rossen Hristov (https://github.com/hamorphis)", - "license": "Apache-2.0", - "bugs": "https://github.com/hamorphis/nativescript-ios-uuid/issues", - "homepage": "https://github.com/hamorphis/nativescript-ios-uuid" + "license": "Apache-2.0" } From 481ba68b76126f36f09dd7995324e25945d772a7 Mon Sep 17 00:00:00 2001 From: Richard Date: Tue, 12 Sep 2017 14:03:52 +0800 Subject: [PATCH 2/6] export --- index.android.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/index.android.js b/index.android.js index 1754c7f..602640f 100644 --- a/index.android.js +++ b/index.android.js @@ -2,4 +2,6 @@ var device = require('platform'); function getUUID() { return device ? device.uuid : ""; -} \ No newline at end of file +} + +exports.getUUID = getUUID; \ No newline at end of file From 97b43752ce04729add286299c7a7b36eb2624b53 Mon Sep 17 00:00:00 2001 From: Richard Date: Tue, 12 Sep 2017 14:14:56 +0800 Subject: [PATCH 3/6] fix module path --- index.android.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.android.js b/index.android.js index 602640f..44be81c 100644 --- a/index.android.js +++ b/index.android.js @@ -1,4 +1,4 @@ -var device = require('platform'); +var device = require('../tns-core-modules/platform/platform'); function getUUID() { return device ? device.uuid : ""; From 92e7c5ef72a8221b68d5932f3dd4845706ae84ef Mon Sep 17 00:00:00 2001 From: Richard Date: Tue, 12 Sep 2017 14:47:00 +0800 Subject: [PATCH 4/6] update --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index b19b250..3da76d7 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,17 @@ -# NativeScript iOS UUID +# NativeScript UUID -This is a plugin for iOS that allows you to get a UUID (Universal Unique Identifier) for a device. +This is a plugin for Nativescript that allows you to get a UUID (Universal Unique Identifier) for a device. Inspired from [`StackOverflow: How to preserve identifierForVendor in ios after uninstalling ios app on device?`] (http://stackoverflow.com/questions/21878560/how-to-preserve-identifierforvendor-in-ios-after-uninstalling-ios-app-on-device). Uses [`SSKeychain Cocoa Pod`](https://cocoapods.org/pods/SSKeychain). ## Installation -`tns plugin add nativescript-ios-uuid` +`tns plugin add nativescript-uuid` ## Usage ``` -var plugin = require("nativescript-ios-uuid"); +var plugin = require("nativescript-uuid"); var uuid = plugin.getUUID(); console.log("The device UUID is " + uuid); ``` From 371f1f0aeee211b8c8f2901f473db2d3aa842edd Mon Sep 17 00:00:00 2001 From: Qanah Date: Thu, 24 May 2018 14:06:30 +0300 Subject: [PATCH 5/6] Update index.android.js --- index.android.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.android.js b/index.android.js index 44be81c..0283f3d 100644 --- a/index.android.js +++ b/index.android.js @@ -1,7 +1,7 @@ -var device = require('../tns-core-modules/platform/platform'); +var device = require('tns-core-modules/platform/platform'); function getUUID() { return device ? device.uuid : ""; } -exports.getUUID = getUUID; \ No newline at end of file +exports.getUUID = getUUID; From aa749c9baaa508847a01b3c9885996771cb70685 Mon Sep 17 00:00:00 2001 From: ikysylevych Date: Fri, 24 May 2019 00:22:13 +0300 Subject: [PATCH 6/6] Upgrade to SAMKeychain --- README.md | 28 ++++++++++++++++++++++------ index.ios.js | 4 ++-- platforms/ios/Podfile | 2 +- 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 3da76d7..487e57c 100644 --- a/README.md +++ b/README.md @@ -2,16 +2,32 @@ This is a plugin for Nativescript that allows you to get a UUID (Universal Unique Identifier) for a device. -Inspired from [`StackOverflow: How to preserve identifierForVendor in ios after uninstalling ios app on device?`] (http://stackoverflow.com/questions/21878560/how-to-preserve-identifierforvendor-in-ios-after-uninstalling-ios-app-on-device). +Inspired from [`StackOverflow: How to preserve identifierForVendor in ios after uninstalling ios app on device?`](http://stackoverflow.com/questions/21878560/how-to-preserve-identifierforvendor-in-ios-after-uninstalling-ios-app-on-device). -Uses [`SSKeychain Cocoa Pod`](https://cocoapods.org/pods/SSKeychain). +Uses [`SAMKeychain Cocoa Pod`](https://cocoapods.org/pods/SAMKeychain). ## Installation -`tns plugin add nativescript-uuid` + +Run the following command from the root of your project: + +``` +tns plugin add nativescript-uuid +``` ## Usage + +#### JavaScript +```js + const nsUuid = require("nativescript-uuid"); + + const uuid = nsUuid.getUUID(); + console.log(`The device UUID is ${uuid}`); ``` -var plugin = require("nativescript-uuid"); -var uuid = plugin.getUUID(); -console.log("The device UUID is " + uuid); + +#### TypeScript +```typescript + import {getUUID} from 'nativescript-uuid'; + + const uuid = getUUID(); + console.log(`The device UUID is ${uuid}`); ``` diff --git a/index.ios.js b/index.ios.js index 1b108f8..71f373e 100644 --- a/index.ios.js +++ b/index.ios.js @@ -1,9 +1,9 @@ function getUUID() { var appName = NSBundle.mainBundle.infoDictionary.objectForKey(kCFBundleNameKey); - var strApplicationUUID = SSKeychain.passwordForServiceAccount(appName, "incoding"); + var strApplicationUUID = SAMKeychain.passwordForServiceAccount(appName, "incoding"); if (!strApplicationUUID){ strApplicationUUID = UIDevice.currentDevice.identifierForVendor.UUIDString; - SSKeychain.setPasswordForServiceAccount(strApplicationUUID, appName, "incoding"); + SAMKeychain.setPasswordForServiceAccount(strApplicationUUID, appName, "incoding"); } return strApplicationUUID; diff --git a/platforms/ios/Podfile b/platforms/ios/Podfile index 749bc13..456d93d 100644 --- a/platforms/ios/Podfile +++ b/platforms/ios/Podfile @@ -1 +1 @@ -pod 'SSKeychain' +pod 'SAMKeychain', '~> 1.5.3'