Hi,
I'm implementing a ANE to register to a private PushNotification System. I need to check out whenever "didReceiveRemoteNotification" is launched and send some data to the native SDK.
When extensionContextInitializer is launched, I inject the functions in a custom delegate. And it works fine when the mobile receives the notification and the app is opened on background.
NSString *newClassName = [NSStringstringWithFormat:@"Custom_%@", NSStringFromClass(objectClass)];
Class modDelegate = objc_allocateClassPair(objectClass, [newClassName UTF8String], 0);
SEL selectorToOverride1 = @selector(application:didRegisterForRemoteNotificationsWithDeviceToken:);
SEL selectorToOverride2 = @selector(application:didFailToRegisterForRemoteNotificationsWithError:);
SEL selectorToOverride3 = @selector(application:didReceiveRemoteNotification:);
// get the info on the method we're going to override
Method m1 = class_getInstanceMethod(objectClass, selectorToOverride1);
Method m2 = class_getInstanceMethod(objectClass, selectorToOverride2);
Method m3 = class_getInstanceMethod(objectClass, selectorToOverride3);
// add the method to the new class
class_addMethod(modDelegate, selectorToOverride1, (IMP)didRegisterForRemoteNotificationsWithDeviceToken, method_getTypeEncoding(m1));
class_addMethod(modDelegate, selectorToOverride2, (IMP)didFailToRegisterForRemoteNotificationsWithError, method_getTypeEncoding(m2));
class_addMethod(modDelegate, selectorToOverride3, (IMP)didReceiveRemoteNotification, method_getTypeEncoding(m3));
// register the new class with the runtime
objc_registerClassPair(modDelegate);
// change the class of the object
object_setClass(delegate, modDelegate);
In my opinion, when the app has not been opened yet, this injection is called AFTER the app is opened from the Push Notification, so my custom delegate function is not called.
Do you know how can I solve this problem?
I've tried also (found here Using push notifications in AIR iOS apps | Adobe Developer Connection) But this function is never trigered (???)
remoteNot.addEventListener(RemoteNotificationEvent.NOTIFICATION,notificationHandler);
public function notificationHandler(e:RemoteNotificationEvent):void{
tt.appendText("\nRemoteNotificationEvent type: " + e.type +"\nbubbles: "+ e.bubbles + "\ncancelable " +e.cancelable);
for (var x:String in e.data) { tt.text += "\n"+ x + ": " + e.data[x];
}
}
Any ideas?, thanks!
Clik here to view.