2013-01-19 57 views
0

我想第一次为我的应用程序设置APNS,并有一个关于如何设置与特定设备ID相关联的用户的问题。我在阅读以下内容:APNS与Django的IOS通知

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,电子邮件,密码等。有没有办法在用户登录后延迟所有这些?或者这是我在推出时必须要做的事情?

回答

0

似乎答案是否定的。最好的办法是让appDelegate记住deviceToken,然后在稍后时间(登录后等)发送该设备的用户注册。