1

In IOS I have this function :

- (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);

my particular problem is this param :

withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler

i translate it like

procedure userNotificationCenterWillPresentNotificationWithCompletionHandler(center: UNUserNotificationCenter;
                                                                             willPresentNotification: UNNotification;
                                                                             withCompletionHandler: pointer);
var aImp: procedure(self: pointer; _cmd: pointer; const options); cdecl;
    aOptions: UNNotificationPresentationOptions;
begin

  @aImp := imp_implementationWithBlock(withCompletionHandler);
  aOptions := UNNotificationPresentationOptionAlert;
  aImp(self, nil, aOptions);
  imp_removeBlock(@aImp);

end;

but it's not work ! i thing i do something wrong when passing the options

i declare the imp function like

var aImp: procedure(self: pointer; _cmd: pointer; const options); cdecl;
aOptions := UNNotificationPresentationOptionAlert;

but maybe not the good way, i try to declare it like

var aImp: procedure(self: pointer; _cmd: pointer; options: pointer); cdecl;
aOptions := pointer(UNNotificationPresentationOptionAlert);

or like

var aImp: procedure(self: pointer; _cmd: pointer; options: nsuinteger); cdecl;
aOptions := UNNotificationPresentationOptionAlert;

none work :( any idea(s) of what I miss ?

1 Answer 1

1

a little crazy how i found it (trying all the possible and impossible combinations) but i found it !

var aImp: procedure(options: nsuinteger); cdecl;

yes simple like this ...

Sign up to request clarification or add additional context in comments.

1 Comment

This seems to be in contradiction to Apple's documentation: developer.apple.com/reference/objectivec/…, but I'm glad you found the answer!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.