Reskinning Game- Need to Register for Notifications in AppDelegate.cpp

Hey guys! I’m pretty new to the iOS/mobile/game development world, and really only have experience with it in helping out my uncle’s company. I’ll skip the boring stuff, but I’m a web developer new to all things mobile.

I have a Cocos2d game that we are reskinning, but we also need to add Push Notifications to it.
It’s written completely in C++, which is awesome and I’ve learned a lot working with it. (And frankly enjoy it much more than Obj-c) However, the AppDelegate is also written in C++, and I believe that takes away my ability to work with a lot of the application methods used to register/receive remote notifications.

Specifically, I need to implement the following methods, but can’t/don’t know how or where to do it. I’ve done it on another reskinned game, but it was Obj-C, so the methods could be dropped in.

- (void) application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings {
  [application registerForRemoteNotifications];
}

- (void)application:(UIApplication *)anApplication didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)aDeviceToken {
 // Send the deviceToken to the server
}

- (void)application:(UIApplication *)anApplication didReceiveRemoteNotification:(NSDictionary *)aUserInfo {
// Handle the notification and do stuff based on it
}

Any help would be awesome! I’ve been scouring the internets, but so far all I’ve found is people either not using push notifications, or they are using a standard AppDelegate.m or AppDelegate.swift .

I’ll post my AppDelegate.cpp code if it will help, but from what I’ve seen elsewhere, it’s pretty standard.

I’ve tried adding a second AppDelegate to handle those, but the code failed to compile with a duplicate _main error after that. I’ve considered rewriting the AppDelegate.cpp to instead be .m/.mm/.swift, but not sure if I’ll be able to get everything right. That’s what I’ll try next if nobody has any other ideas.

Hey, check onesignal sdk they have all you need:)

OneSignal looks really cool! They handle a lot of Push Notification stuff… However, I don’t think they solve my problem.

It looks like, at least at first glance, you still need to hook in to the app and register notifications yourself. Which is the main problem. That’s the part that I can’t do here.

EDIT:
I take that back! Looks like they do use the AppDelegate.cpp file.
Will definitely be looking into it. Thanks so much! :smile:

Only 1 code block:) and additional function will make it work:) so it is extra east to setup.