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

しかし、両方の値を同じにする必要があるため、次のいずれかの解決策が必要です。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 に答える