Skip to content

Safari plugin: Part 1 #15

@filimo

Description

@filimo

Important

  1. Info.plist
<dict>
    <key>Allowed Domains</key>
    <array>
        <string>*</string>
    </array>
    <key>Level</key>
    <string>All</string>
</dict>
  1. Info.plist
<key>NSAppleEventsUsageDescription</key>
<string>ReaderTranslator communicates with other apps on your Mac when you choose to share a news item.</string>
  1. Info.plist
<key>AppIdentifierPrefix</key>
<string>$(AppIdentifierPrefix)</string>
  1. Add App Group
  2. See Important Implement macOS project target #20

Info

My question about CFNotificationCenterGetDarwinNotifyCenter on stackoverlow
Sharing data between iOS apps and app extensions
How to Build Safari App Extensions
More articles about it in #6

If the extension runs as a separate process then this is impossible: Memory allocated in one process is not available in a different process. – Martin R 9 hours ago
Sound strange I see CFNotificationCenterGetDarwinNotifyCenter manage it. – Victor Kushnerov 9 hours ago

Compare developer.apple.com/documentation/corefoundation/…: if center is a Darwin notification center then object and userInfo are ignored. – Martin R 9 hours ago
How max length a message name? – Victor Kushnerov 9 hours ago

I have no idea ... – Martin R 9 hours ago
I guess I have to use combine UserDefaults and CFNotificationCenterGetDarwinNotifyCenter to send some long text? – Victor Kushnerov 9 hours ago

Compare stackoverflow.com/a/35206961/1187415. – Martin R 9 hours ago
Thanks for point out that object and userInfo are ignored. I missed it. Why use UnsafeRawPointer in same process? – Victor Kushnerov 8 hours ago

Here is an example where the raw pointer is used to pass a pointer to a class instance to the callback function. – Martin R 8 hours ago
I see but I can't imagine a situation why it is necessary since class it is reference type? – Victor Kushnerov 8 hours ago
When I call some method with class type parameter I send a pointer. – Victor Kushnerov 8 hours ago

CFNotificationCenterPostNotification is actually a C function, and the callback is also a pure C function. C knows nothing about Swift types or instance pointers. That's why the object parameter is a UnsafeRawPointer (the Swift equivalent of void *). – Martin R 8 hours ago
Awesome, I got it now, thanks. – Victor Kushnerov 8 hours ago
I add stackoverflow.com/a/58188965/4067700 to help guys to get the goal quickly. The question is closed by me thanks @MartinR. – Victor Kushnerov 7 hours ago

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions