我第一次尝试为我的应用程序设置 APNS,并且对如何设置与特定设备 ID 关联的用户有疑问。我正在阅读以下内容:
https://github.com/stephenmuss/django-ios-notifications
我能够完成所有设置和一切,我正试图为 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、电子邮件、密码等。有没有办法在用户登录后延迟所有这些?或者这是我在发布时必须做的事情?