Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/japlscript/japlcontact
Java API for Apple's Contacts app (macOS)
https://github.com/japlscript/japlcontact
apple applescript contacts japlscript java macos
Last synced: about 2 months ago
JSON representation
Java API for Apple's Contacts app (macOS)
- Host: GitHub
- URL: https://github.com/japlscript/japlcontact
- Owner: japlscript
- License: lgpl-2.1
- Created: 2021-09-18T14:08:17.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-07-14T08:02:47.000Z (over 2 years ago)
- Last Synced: 2023-08-01T07:18:27.494Z (over 1 year ago)
- Topics: apple, applescript, contacts, japlscript, java, macos
- Language: Java
- Homepage:
- Size: 482 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![LGPL 2.1](https://img.shields.io/badge/License-LGPL_2.1-blue.svg)](https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.tagtraum/japlcontact/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.tagtraum/japlcontact)
[![Build and Test](https://github.com/japlscript/japlcontact/workflows/Build%20and%20Test/badge.svg)](https://github.com/japlscript/japlcontact/actions)# Japlcontact
*Japlcontact* is a Java API for the Apple Contacts app (macOS) based on
[JaplScript](https://github.com/japlscript/japlscript).## Installation
Japlcontact is released via [Maven](https://maven.apache.org).
You can install it via the following dependency:```xml
com.tagtraum
japlcontact```
The Maven artifacts also contain sources and javadocs.
If you are using [modules](https://en.wikipedia.org/wiki/Java_Platform_Module_System),
its name is `tagtraum.japlcontact`.## Usage
To use the generated code, do something like this:```java
import com.tagtraum.macos.contacts.Application;public class GetMyCard {
public static void main(final String[] args) {
// get application
final Application application = Application.getInstance();
final Person card = application.getMyCard();
System.out.println("My Card: " + card.getFirstName() + " " + card.getLastName());
}
}
```## API
You can find the complete [API here](https://japlscript.github.io/japlcontact/com/tagtraum/macos/contacts/package-summary.html).
## AppleScript Sandbox
Since macOS 10.14 (Mojave), Apple imposed a sandbox on AppleScript. Therefore
you may see dialog boxes requesting authorization to perform certain actions.
After a while, these boxes simply disappear and there does not seem to be an easy
way to authorize your app. In this case, you need to open the system preferences,
navigate to *Security & Privacy*, *Privacy*, and then *Automation*, and make
sure your app is allowed to remote control whatever app you are trying to remote
control (see also [this article](https://blog.beatunes.com/2018/10/beatunes-on-mojave-and-windows-10-dark.html)).If you are shipping a real app with a UI and not just a command line tool, you
need to customize the sandbox permission dialog. You can do so by adding
the key `NSAppleEventsUsageDescription` to your app bundle's `/Contents/Info.plist`
file. For example:[...]
NSAppleEventsUsageDescription
SuperMusic uses AppleEvents to access your Music.app library,
e.g., to set BPM values or create playlists.
[...]Apple's documentation for the keyword is [here](https://developer.apple.com/documentation/bundleresources/information_property_list/nsappleeventsusagedescription).
**IMPORTANT** Counterintuitively, the bundle id for the Contacts app is `com.apple.AddressBook`. Should you
need to reset the sandbox using `tccutil`, you need to specify either `com.apple.AddressBook`
or just `AddressBook`. `Contacts` or `com.apple.Contacts` won't work.