← Back to Upcase

iOS Device token when the user deletes the app


(Charlieanna) #1

I have a device token for each registered user on ios for sending the push notifications. Now when the user uninstalls the app and installs it again, he still receives the push even though he hasnt logged in.

I don’t to be sending him the pushes if he has not logged in again yet.

What can I do for this? Should I try to remove his device token when he deletes the app?

I am using this for each time the device starts

 NSUserDefaults  *defaults = [NSUserDefaults standardUserDefaults];
    NSString        *uuidString    = [defaults objectForKey: @"device_identifier"];
    
    if (!uuidString)
    {
        uuidString = (NSString *) CFUUIDCreateString (NULL, CFUUIDCreate(NULL));
        [defaults setObject: uuidString forKey: @"device_identifier"];
        [defaults synchronize]; // handle error
    }
    
    NSString *deviceToken = [[devToken description] stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"<>"]];
    deviceToken = [deviceToken stringByReplacingOccurrencesOfString:@" " withString:@""];

and sending the deviceToken along with the registration id…

and also when the user signs up I send his user id along with the deviceToken to identify the user.

But when the users resinstalls the app, the device still receives the push even though he has not logged in yet.