I've set up a Notification Content Extension for my app, but it's not getting called(tried both local and remote push). I've read the Apple dev guide, and I've set up everything as it says. https://developer.apple.com/documentation/usernotificationsui/customizing_the_appearance_of_notifications
I've looked over the common issues (setting proper deployment targets and setting category identifiers from the backend and in the .plist)
After receiving the notification, I'm not able to get the expanded view and neither is the didReceive(_ notification: UNNotification) of my extension view controller getting invoked. Is there something I'm missing while doing the extension setup, I m not able to figure out the problem?
Also, I m not able to understand this note from apple
"Notification content app extensions are supported only in iOS apps"
when all the Notification content Extension APIs are provided for MacOS also?
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I have created a Notification service extension as target to the main MacOS application. I want to update the content of my remote notification using this extension but due to some reason the extension is not getting invoked to update my remote notification.
The auto execution of the below method seems to fail for my app extension.
didReceive(_ request: UNNotificationRequest,
withContentHandler contentHandler: @escaping
(UNNotificationContent) -> Void)
I have tried the suggested solutions in this link but it did not help. Maybe there are some differences to using Notification service for MacOS and ios that I m not aware.
I am able to send normal remote notifications using the curl command, but it is not invoking the notification service extension. Below is the curl command.
curl -v --header "apns-topic: $TOPIC" --header "apns-push-type: alert" --header "authorization: bearer $AUTHENTICATION_TOKEN" --data '{"aps": {"mutable-content": 1,"alert": {"title": "Encrypted title","body": "Encrypted body"}},"MEETING_ORGANIZER": "MyMeet"}' --http2 https://${APNS_HOST_NAME}/3/device/${DEVICE_TOKEN}
Is there anything I m missing that is causing this problem?
I m using Mac Automator app to add new actions to the right click quick menu for files and folder. As can we seen in the image we have a number of actions available for mail app, Calendar, photos and other apps. I wanted to know whether something similar can be done for my app. I wanted to list my app in the library and provide some similar action options. Can it be done?
I have been using the Cpp-Swift Interoperability in Xcode15 for direct communication between Cpp and Swift code. It required a few Build settings changes for the Swift Compiler and creating clang modules to access cpp code in swift.
I wanted to use this interoperability feature in my visual studio project which is using Cmake. I m not able to find the Xcode attribute property flags for my cmake to enable this interoperability. Can someone help with this?
I am creating an Xcode project using xcode generator in Cmake. The project has a library which contains cpp files and swift files. I m trying to test swift-cpp interoperability that is introduced in xcode15 to perform direct cpp calls from swift and vice-versa. For this to work, we need to set a xcode build setting 'C++ and Objective-C Interoperability' which I m doing via cmake, Below is my cmake file:
cmake_minimum_required(VERSION 3.18)
project(CxxInterop LANGUAGES CXX Swift)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED YES)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_Swift_LANGUAGE_VERSION 5.0)
add_executable(CxxInterop ./Sources/CxxInterop/main.swift
./Sources/CxxInterop/Student.cpp
)
#include the directory with modulemap file and Student.hpp
target_include_directories(CxxInterop PUBLIC
${CMAKE_SOURCE_DIR}/Sources/CxxInterop)
#setting the xcode C++ and Objective-C Interoperability setting
target_compile_options(CxxInterop PRIVATE
"-cxx-interoperability-mode=default")
when building the generated xcode project I get the error unknown argument: '-cxx-interoperability-mode=default'.
However the weird thing is when I separate out the cpp code in a different library and swift files in a different one, then this works and I m able to invoke the cpp methods in my swift file after importing the clang module from the module map file.
Is there any reason to why having cpp and swift files in same library producing this error? I m following this link to setup the project via cmake.
I am having a usecase where I wanted to detect the system language change event under OS X. I went throught the available options in NSNotification.Name , but did not find anything helpful. I found a similar link but it seems to be no longer applicable.
Any help on how this can be achieved?
I wanted to add some dock menu options for my application when it is not running. These dock menu options can be used to launch the application. I came across dock TilePlugin that can be used to add these dock options. But one of the comments in this forum discussion mentions that these Plugins are not allowed if you want ot publish your application in the appStore.
Can someone confirm this? If this is true, then Is there some other solution that can be used to add the dock options which appear when the application is not running, and can be used to launch the application?
Also do the recent open Files appear using this plugin mechanism?
The notification parameter in DidFinishLaunching contains a key LaunchIsDefaultLaunchKey which according to Apple documentation is:
The value for this key is an NSNumber containing a Boolean value. The value is false if the app was launched to open or print a file, to perform a Service action, if the app had saved state that will be restored, or if the app launch was in some other sense not a default launch. Otherwise its value will be true.
I m not able to understand the exact usecase for this parameter, like where can we make use of this parameter.
Can I use this key to identify If my application was launched using a universal link?
I have a mac application that is configured to have a universal link. Clicking the universal link launches my application. The documentation says that the link is received in the application(_:continue:restorationHandler:) delegate method which is invoked very late in the application lifecycle after applicationDidBecomeActive.
I have the initialisation code of my app in applicationWillFinishLaunching method. Is there any way the Universal link can be received early, so that I can show the appropriate application window based on the universal link parameters? Is there any other delegate that receives the universal link?
I have the below code where my swift code calls a cpp function. In this the swift calls a cpp function and passes a swift 'String' as argument to it, which is then received in the cpp code as 'const char *'. This conversion works without any errors. Is this a documented behaviour in cpp-swift interop and is this safe to use?
Swift side:
internal static func CharCheck (pSentence: String) -> Void
{
TWSoundLogic.CharacterSoundCount (pSentence)
}
In the C++ side,
void TWSoundLogic::CharacterSoundCount (const char * pSentence)
{
..
}
However, on returning a String type from a swift function and trying to receive it as a const char* in c++, it gives an error in cpp No viable conversion from 'swift::String' to 'const char *' . Why does it not allow to return, but it allows to pass as argument? Can someone explain this behaviour?
I am building a macOS project where I m creating a thread using pthread in cpp. I am setting the QOS class using the pthread_attr_set_qos_class_np and later checking the value of the QOS class using the pthread_attr_get_qos_class_np. These calls are successful but the QOS class is not being set. Below is the cpp function that I m invoking from my swift code.
bool CppThread::CreateThread ()
{
pthread_t threadId;
pthread_attr_t attr;
qos_class_t qos_class;
int relative_priority;
int rc = pthread_attr_init(&attr);
if (rc) {
printf ("pthread_attr_init failed");
}
if (pthread_attr_set_qos_class_np (&attr, QOS_CLASS_BACKGROUND, 5)) {
printf ("pthread_attr_set_qos_class_np failed\n");
}
int retval = pthread_create(&threadId, &attr, threadFunction, NULL);
if (retval) {
std::cerr << "Error creating thread" << std::endl;
return false;
}
if (pthread_attr_get_qos_class_np (&attr, &qos_class, &relative_priority)) {
printf ("pthread_attr_get_qos_class_np failed\n");
}
printf ("QoS class: %d, Relative priority: %d\n", qos_class, relative_priority);
pthread_join(threadId, NULL); // Wait for thread to finish
std::cout << "Thread finished" << std::endl;
return true;
}
OUTPUT:
QoS class: 0, Relative priority: 0
Thread finished
I have tried setting multiple QOS values but the output always shows the QOS class value as 0. Why is it not getting set?
We can see Xcode supports to generate code coverage for unit test bundles. Does it has any support for generating code coverage report for a regular application/bundle. What we want to try is that can I check for my certain application how much code coverage is being done.
If Xcode does not have any support for this, what apple suggest us to do for this ?
I have a macOS app project implementing the direct Cpp-swift interop mechanism. The project some cpp classes and few Swift class. I wanted to pass a cpp object to a swift function as parameter, so I can use it in my swift code. But the documentation is not very clear on how to do this. Can some please share a code snippet explaining how can I achieve this?
I have tried the below code, but it is giving linker error.
Swift code:
import StClass_modulemap
public class SwiftClass {
..
public static func getCppObj (pObj: inout StClass) -> Void
{
...
}
}
Cpp code:
#include "Student.hpp"
#include "StClass.hpp"
#include <InteropLib-Swift.h>
using namespace InteropLib;
void Student::Introduce() {
//creating cpp to be passed to swift
// StClass StObj(50);
// Teacher::getCppObj(StObj);
std::cout<< "header included in hpp " <<std::endl;
}
calling Student::Introduce is giving a linker error for StClass
I have a very basic macOS bundled application with just the empty delegate methods implemented. I am wanting to launch this application as a daemon but when I am loading my daemon, it fails to run with the error:
The application cannot be opened for an unexpected reason, error=Error Domain=NSCocoaErrorDomain Code=257 "The file “GUIDaemon” couldn’t be opened because you don’t have permission to view it." UserInfo={NSURL=file:///Users/vipul.g/Library/Developer/Xcode/DerivedData/Build/Products/Debug/GUIDaemon.app/, NSFilePath=/Users/vipul.g/Library/Developer/Xcode/DerivedData/Build/Products/Debug/GUIDaemon.app, NSUnderlyingError=0x600000034870 {Error Domain=NSPOSIXErrorDomain Code=13 "Permission denied"}}
Below is my daemon property list file. Can someone help what am I doing wrong here. I have made sure that my app has all the permission required.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.demo.GUIDaemonApp.plist</string>
<key>RunAtLoad</key>
<true/>
<key>StandardErrorPath</key>
<string>/Users/vipul.g/MySystemWorkspace/stderr.log</string>
<key>StandardOutPath</key>
<string>/Users/vipul.g/MySystemWorkspace/stdout.log</string>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/open</string>
<string>/Users/vipul.g/Library/Developer/Xcode/DerivedData/Build/Products/Debug/GUIDaemon.app</string>
</array>
</dict>
</plist>
I have a very basic macOS bundled application with just the empty delegate methods implemented. I want to run this application as a daemon, and so I have created the below daemon property list file.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.demo.GUIDaemon.plist</string>
<key>RunAtLoad</key>
<true/>
<key>StandardErrorPath</key>
<string>/Users/vipul.g/MySystemWorkspace/stderr.log</string>
<key>StandardOutPath</key>
<string>/Users/vipul.g/MySystemWorkspace/stdout.log</string>
<key>Program</key>
<string>/Users/vipul.g/Library/Developer/Xcode/DerivedData/Build/Products/Debug/GUIDaemon.app/Contents/MacOS/GUIDaemon</string>
</dict>
</plist>
After loading the daemon, I can see the application running in the Activity monitor, but only the below delegates can be observed getting invoked in the logs. Other delegate like didBecomeActive, willResignActive are not being invoked. Is this the expected behaviour for launching a bundled application as daemon? Also there are some additional items logged, which I m not sure If they are denoting If something went wrong. Can someone confirm what should be expected?
024-03-14 18:09:59.452 GUIDaemon[45883:5345352] inside main.swift
2024-03-14 18:09:59.454 GUIDaemon[45883:5345352] applicationWillFinishLaunching(_:)
2024-03-14 18:09:59.567 GUIDaemon[45883:5345352] TISFileInterrogator updateSystemInputSources false but old data invalid: currentCacheHeaderPtr nonNULL? 0, ->cacheFormatVersion 0, ->magicCookie 00000000, inputSourceTableCountSys 0
Keyboard Layouts: duplicate keyboard layout identifier -17410.
Keyboard Layouts: keyboard layout identifier -17410 has been replaced with -28673.
Keyboard Layouts: duplicate keyboard layout identifier -30769.
Keyboard Layouts: keyboard layout identifier -30769 has been replaced with -28674.
Keyboard Layouts: duplicate keyboard layout identifier -14934.
Keyboard Layouts: keyboard layout identifier -14934 has been replaced with -28675.
2024-03-14 18:09:59.664 GUIDaemon[45883:5345352] applicationDidFinishLaunching(_:)