Device Tocken will Change after install from diawi or TestFlight? So Push notification is not coming

后端 未结 2 760
有刺的猬
有刺的猬 2021-02-06 19:04

I\'m currently creating an app that needs to receive push notifications from a server.

When I got the device token, I send it to my server and save it into DB,

M

2条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-06 20:01

    I found answered of my question.

    Never use your NSUserDefaults' key as @"key".

    For example what I have previously used.

    [[NSUserDefaults standardUserDefaults] setObject:deviceToken forKey:@"key"];
    [[NSUserDefaults standardUserDefaults] synchronize];
    

    And what I am using now.

    [[NSUserDefaults standardUserDefaults] setObject:deviceToken forKey:@"token"];
    [[NSUserDefaults standardUserDefaults] synchronize];
    

    And now push notification is coming as it is.

    So conclusion is never used your key name @"key". I don't know why but may be some preference is using this @"key" by default.

    Thanks.

提交回复
热议问题