简体   繁体   中英

iOS notifications

I'd like my app to have save a username and password for each user and login with it, unless it is changed to another user.
I was asking myself how I can send the Push notifications to the relevant device ?

What kind of data do I need to send alongside the username and password each time a username/password have changed or newly entered ?

Implement this method in your AppDelegate, the value of "str" represents the unique string for the device. Use this in addition to username and password to uniquely identify a user on a specific device.

- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { 

    NSString *str = [NSString 
        stringWithFormat:@"Device Token=%@",deviceToken];
    NSLog(str);

}

A prerequisite for this is to call this line of code somewhere in your application, usually from applicationDidFinishLaunching

[[UIApplication sharedApplication] 
    registerForRemoteNotificationTypes:
    (UIRemoteNotificationTypeAlert | 
     UIRemoteNotificationTypeBadge | 
     UIRemoteNotificationTypeSound)];

This is a very good end to end reference on programming iOS Push Notifications (scroll way down past the configuration information to find the programming techniques): http://mobiforge.com/developing/story/programming-apple-push-notification-services

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM