1

我正在寻找一种从 PhoneGap 和本机 Objective-C 环境中的 iPad 获取设备 UUID 的方法。问题是PhoneGap 只给了我设备UUID 的散列版本。例如:

1) device.uuid = E0AB7C8C-EFEE-4EB1-9B8F-A543575390A0
2) [[UIDevice currentDevice] uniqueIdentifier] = 75579DE5-98C7-53B6-B2AD-7F348662CB5D

但是因为我需要两个值相同,所以我需要以下解决方案之一 1)如何像 PhoneGap 在 Objective-C 中一样对 [device uniqueIdentifier] 进行哈希处理。2) 如何从 PhoneGap (JavaScript) 获取原始(非散列)设备的 UUID。

有人知道如何实现这一目标吗?提前致谢!

4

2 回答 2

1

uniqueIdentifier自 iOS 5 起已弃用。您根本不应该再使用它。

于 2012-06-04T00:11:20.220 回答
1

由于 PhoneGap 是开源的,您可以自己查看它是如何生成 UUID 的。

这是 PhoneGap 使用的方法(复制自1.7.0)。我还复制了 Apache 许可证,以防万一。

/*
 Licensed to the Apache Software Foundation (ASF) under one
 or more contributor license agreements.  See the NOTICE file
 distributed with this work for additional information
 regarding copyright ownership.  The ASF licenses this file
 to you under the Apache License, Version 2.0 (the
 "License"); you may not use this file except in compliance
 with the License.  You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing,
 software distributed under the License is distributed on an
 "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 KIND, either express or implied.  See the License for the
 specific language governing permissions and limitations
 under the License.
 */

- (NSString*) uniqueAppInstanceIdentifier
{
    // full path to the app folder
    NSString* bundlePath = [[[NSBundle mainBundle] bundlePath]
        stringByDeletingLastPathComponent];

    // return only the folder name (a GUID)
    return [bundlePath lastPathComponent];
}
于 2012-06-04T00:41:38.750 回答