在App Purchase iOS中访问AppleId [英] In App Purchase iOS access AppleId

查看:212
本文介绍了在App Purchase iOS中访问AppleId的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在购买完成后进行应用内购买(电子邮件或内部ID)时访问用户在身份验证对话框中输入的苹果ID?

解决方案

在官方应用程序中,无法访问它,因为它会带来很大的安全漏洞(例如,可以轻松地将垃圾邮件发送到指定的电子邮件地址)。 / p>

但是,如果您使用的是越狱设备,则可以从钥匙串获取必要的信息。相应的钥匙串项目的 svce 键设置为 com.apple.itunesstored.token ,以及电子邮件地址对应 acct 键。这些条目的安全级别是 kSecClassGenericPassword 。只需确保使用相应的权利对您的应用进行协同设置(您需要keychain-access-groups=*)。



检索所需信息的实际示例如下:

  #import< CoreFoundation /CoreFoundation.h> 
#import< Foundation / Foundation.h>
#import< Security / Security.h>

int main()
{
NSMutableDictionary * query = [NSMutableDictionary dictionary];
[query setObject:kSecClassGenericPassword forKey:kSecClass];
[query setObject:kSecMatchLimitAll forKey:kSecMatchLimit];
[query setObject:kCFBooleanTrue forKey:kSecReturnAttributes];
[query setObject:kCFBooleanTrue forKey:kSecReturnRef];
[query setObject:kCFBooleanTrue forKey:kSecReturnData];
NSArray * items = nil;
SecItemCopyMatching(查询和&项目);

for(NSDictionary * item in items){
if([[item objectForKey:@svce] isEqualToString:@com.apple.itunesstored.token]){
NSLog(@找到iTunes Store帐户:%@,[item objectForKey:@acct]);
}
}

返回0;
}

entitlements.xml文件(使用代码签名ldid - Sentitlemens.xml二进制文件):

 < plist> 
< dict>
< key> keychain-access-groups< / key>
< array>
< string> *< / string>
< / array>
< / dict>
< / plist>


Is there a way to access apple id that is enter by user in authentication dialog while doing in-app purchase (email or their internal id) after purchase is done?

解决方案

In an official application, there's no way of accessing it, since it would impose great security exploits (for example, one could easily send spam to the specified e-mail address).

However, if you're using a jailbroken device, you can get the necessary information from the keychain. The appropriate keychain items have their svce key set to com.apple.itunesstored.token, and the e-mail address corresponds to the acct key. The security class of these entries is kSecClassGenericPassword. Just make sure you codesign your app using the appropriate entitlements (you'll need "keychain-access-groups" = "*").

An actual example for retrieving the needed information would be something like this:

#import <CoreFoundation/CoreFoundation.h>
#import <Foundation/Foundation.h>
#import <Security/Security.h>

int main()
{
    NSMutableDictionary *query = [NSMutableDictionary dictionary];
    [query setObject:kSecClassGenericPassword forKey:kSecClass];
    [query setObject:kSecMatchLimitAll forKey:kSecMatchLimit];
    [query setObject:kCFBooleanTrue forKey:kSecReturnAttributes];
    [query setObject:kCFBooleanTrue forKey:kSecReturnRef];
    [query setObject:kCFBooleanTrue forKey:kSecReturnData];
    NSArray *items = nil;
    SecItemCopyMatching(query, &items);

    for (NSDictionary *item in items) {
        if ([[item objectForKey:@"svce"] isEqualToString:@"com.apple.itunesstored.token"]) {
            NSLog(@"Found iTunes Store account: %@", [item objectForKey:@"acct"]);
        }
    }

    return 0;
}

The entitlements.xml file (codesign using ldid -Sentitlemens.xml binary):

<plist>
<dict>
    <key>keychain-access-groups</key>
    <array>
        <string>*</string>
    </array>
</dict>
</plist>

这篇关于在App Purchase iOS中访问AppleId的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆