2012-06-03 5 views
1

PhoneGap 및 기본 Objective-C 환경에서 iPad의 장치 UUID를 가져 오는 방법을 찾고 있습니다. 문제는 PhoneGap이 장치 UUID의 해시 버전만을 제공한다는 것입니다. 예를 들어 I가 동일하게 두 값이 필요로PhoneGap device.uuid (VS.) iPad [[UIDevice currentDevice] uniqueIdentifier]

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

하지만, I 해시 방법 다음 해결책 1) 중 하나가 필요 [디바이스 고유 식별자] 정확히 폰갭 오브젝티브 C에서와 같이. 2) PhoneGap (자바 스크립트)에서 원시 (해시가 아닌) 장치의 UUID를 가져 오는 방법.

누군가이 방법을 알고 있습니까? 미리 감사드립니다.

답변

1

PhoneGap은 오픈 소스이기 때문에 UUID가 어떻게 생성되는지 직접 살펴볼 수 있습니다.

PhoneGap에서 사용하는 방법은 다음과 같습니다 (1.7.0에서 복사). 내가해야 할 경우를 대비하여 아파치 라이센스도 재현했다.

/* 
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]; 
} 
2

uniqueIdentifier은 더 이상 iOS 5에서 사용되지 않습니다. 더 이상 사용하지 마십시오.

+0

.. 그리고 그러므로'device.uuid'는 장치의 기능과 정보를 해시 코드를 직접 작성하고 자바 스크립트 기능과 오브젝티브 C의 기능을 모두 달성하기 위해 만들 수 있습니다, 당신의 목적을 위해 충분, 또는 이. 또는 Objective-C uuid 메소드를 호출하고 결과를 JavaScript로 리턴하는 PhoneGap 플러그인을 작성하십시오. – darvids0n

관련 문제