0

初めてアプリに APNS をセットアップしようとしていますが、特定のデバイス ID に関連付けられたユーザーを設定する方法について質問がありました。私は以下を読んでいます:

https://github.com/stephenmuss/django-ios-notifications

http://highonpython.com/index.php/setting-up-ios-push-notifications-apns-with-pythondjango-through-pyapns/

私はすべてのセットアップとすべてを行うことができました.iOSアプリのコードを書こうとしているところです. 私の質問は、iOS アプリの例に従って次のとおりです。

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    UIRemoteNotificationType allowedNotifications = UIRemoteNotificationTypeAlert|UIRemoteNotificationTypeSound|UIRemoteNotificationTypeBadge;

    [[UIApplication sharedApplication] registerForRemoteNotificationTypes:allowedNotifications];
    return YES;
}

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
    NSString * tokenAsString = [[[deviceToken description]
                                 stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"<>"]]
                                stringByReplacingOccurrencesOfString:@" " withString:@""];
    NSURL* url = [NSURL URLWithString:[NSString stringWithFormat:@"http://your_server.com/add_device_token/%@/", tokenAsString]];
    NSMutableURLRequest* request = [[NSMutableURLRequest alloc] initWithURL:url];

    [NSURLConnection connectionWithRequest:request delegate: self];
}

これにより、その特定のデバイスのトークンをサーバーに通知できます。ただし、私のアプリではユーザーがログインする必要があり、ログイン後にユーザー ID、電子メール、パスワードなどを持っています。ユーザーがログインした後、これらすべてを遅らせる方法はありますか? それとも、これは私がローンチ時にしなければならないことですか?

4

1 に答える 1

0

答えはノーのようです。最善の方法は、appDelegate に deviceToken を記憶させ、後で (ログイン後などに) そのデバイスのユーザー登録を送信することです。

于 2013-01-22T14:40:10.910 に答える