[Résolu] remote notification ios8 : didRegister...Settings appelée, pas didRegister...Token

LouLou Membre
janvier 2015 modifié dans API UIKit #1

Salut,


 


SOLUTION: le problème venait de l'appareil, il y avait un problème de réseau, en redémarrant, ça me donne bien les bons logs.


_____________


 


j'essaie de faire marcher le remote notification, j'ai :


le background mode -> remote notification dans le plist


j'ai suivi les étapes de ce thread sur SO


j'ai enregistré un certificate, un app id, un provioning profile, et pour l'instant je teste avec le device connecté au mac


 


voici le code :



- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//register notif
UIUserNotificationType userNotificationTypes = (UIUserNotificationTypeAlert |
UIUserNotificationTypeBadge |
UIUserNotificationTypeSound);
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:userNotificationTypes categories:nil];
[application registerUserNotificationSettings:settings];


return YES;
}

- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
{
//register to receive notifications
[application registerForRemoteNotifications];
NSLog(@didRegisterUser);//bien appelé
}

-(void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {
NSLog(@error here : %@", error);//pas appelé
}

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
/*
// Store the deviceToken in the current installation and save it to Parse.
PFInstallation *currentInstallation = [PFInstallation currentInstallation];
[currentInstallation setDeviceTokenFromData:deviceToken];
currentInstallation.channels = @[; @global ];
[currentInstallation saveInBackground];
*/
NSLog(@did register notif);//pas appelé
}

Auriez-vous une idée?


 


La doc dit :



 


 


After you call the registerForRemoteNotifications method of the UIApplication object, the app calls this method when device registration completes successfully

 


source


 


Donc après l'appel à  registerForRemoteNotifications, la fonction didRegister... devrait être appelée, or elle ne l'est pas.


Réponses

  • GeoffreyGeoffrey Membre
    janvier 2015 modifié #2

    // This is for iOS >= 8.0
    -(void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings;


    // This is for iOS < 8.0
    -(void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken;

  • NiClouNiClou Membre
    janvier 2015 modifié #3

    Effectivement, ça dépend sur quelle version d'iOS tu fais tourner ton projet.

     


     





    // This is for iOS >= 8.0
    -(void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings;


    // This is for iOS < 8.0
    -(void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken;


  • Vérifier peut être si le profil est bien enregistré dans l'application.


  • D'accord, merci, j'essaierai, ça m'enlèverai un poids, je tournai un peu en rond jusqu'à  maintenant  ::)


  • LouLou Membre
    janvier 2015 modifié #6

    EDIT: OK, en fait il y avait un problème avec le réseau de mon portable, en redémarrant, ça m'a remis les bons logs. Merci de vos réponses.


    _______


     


    En fait, didRegister...Settings permet de donner des indications sur le type de notification( son, alerte), mais ça ne donne pas le token. Cette fonction avec le token est censée être appelée avec "registerForRemoteNotifications", mais elle ne l'est pas.


     


    @Maggic : dans les settings "General", la Team a bien le compte enregistré, avec le bon nom. Est-ce qu'il y aurait un moyen de débugger ça? Voir avec des logs d'où vient le problème?


Connectez-vous ou Inscrivez-vous pour répondre.