├── .gitattributes ├── tsconfig.build.json ├── babel.config.js ├── example ├── app.json ├── ios │ ├── File.swift │ ├── JsiContactsExample │ │ ├── Images.xcassets │ │ │ ├── Contents.json │ │ │ └── AppIcon.appiconset │ │ │ │ └── Contents.json │ │ ├── AppDelegate.h │ │ ├── main.m │ │ ├── Info.plist │ │ ├── AppDelegate.m │ │ └── LaunchScreen.storyboard │ ├── JsiContactsExample-Bridging-Header.h │ ├── JsiContactsExample.xcworkspace │ │ ├── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ │ └── contents.xcworkspacedata │ ├── Podfile │ ├── JsiContactsExample.xcodeproj │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── JsiContactsExample.xcscheme │ └── Podfile.lock ├── android │ ├── app │ │ ├── debug.keystore │ │ ├── src │ │ │ ├── main │ │ │ │ ├── res │ │ │ │ │ ├── values │ │ │ │ │ │ ├── strings.xml │ │ │ │ │ │ └── styles.xml │ │ │ │ │ ├── mipmap-hdpi │ │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ │ └── ic_launcher_round.png │ │ │ │ │ ├── mipmap-mdpi │ │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ │ └── ic_launcher_round.png │ │ │ │ │ ├── mipmap-xhdpi │ │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ │ └── ic_launcher_round.png │ │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ │ └── ic_launcher_round.png │ │ │ │ │ └── mipmap-xxxhdpi │ │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── java │ │ │ │ │ └── com │ │ │ │ │ │ └── example │ │ │ │ │ │ └── jsicontacts │ │ │ │ │ │ ├── MainActivity.java │ │ │ │ │ │ └── MainApplication.java │ │ │ │ └── AndroidManifest.xml │ │ │ └── debug │ │ │ │ ├── AndroidManifest.xml │ │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── example │ │ │ │ └── reactnativejsicontacts │ │ │ │ └── ReactNativeFlipper.java │ │ ├── proguard-rules.pro │ │ └── build.gradle │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── settings.gradle │ ├── gradle.properties │ ├── build.gradle │ ├── gradlew.bat │ └── gradlew ├── index.tsx ├── babel.config.js ├── package.json ├── metro.config.js └── src │ └── App.tsx ├── ios ├── JsiContacts.h ├── JsiContacts.mm └── JsiContacts.xcodeproj │ └── project.pbxproj ├── .yarnrc ├── android ├── gradle.properties ├── src │ └── main │ │ ├── AndroidManifest.xml │ │ ├── cpp │ │ ├── java-bindings │ │ │ ├── JHashMap.cpp │ │ │ ├── JArrayList.h │ │ │ ├── JContactsProvider.h │ │ │ ├── JHashMap.h │ │ │ ├── JContactsProvider.cpp │ │ │ ├── JContact.h │ │ │ └── JContact.cpp │ │ ├── JSIJNIConversion.h │ │ ├── ContactHostObject.h │ │ ├── ThreadPool.h │ │ ├── JSIContacts.h │ │ ├── ThreadPool.cpp │ │ ├── nativeInstall.cpp │ │ ├── JSIJNIConversion.cpp │ │ ├── ContactHostObject.cpp │ │ └── JSIContacts.cpp │ │ └── java │ │ └── com │ │ └── mrousavy │ │ └── jsi │ │ └── contacts │ │ ├── JsiContactsJSIPackage.java │ │ ├── JsiContactsPackage.java │ │ ├── JsiContactsModule.java │ │ ├── Contact.java │ │ └── ContactsProvider.java ├── CMakeLists.txt └── build.gradle ├── .editorconfig ├── .github └── FUNDING.yml ├── react-native-jsi-contacts.podspec ├── tsconfig.json ├── scripts └── bootstrap.js ├── .gitignore ├── LICENSE ├── src └── index.tsx ├── README.md ├── package.json └── CONTRIBUTING.md /.gitattributes: -------------------------------------------------------------------------------- 1 | *.pbxproj -text 2 | # specific for windows script files 3 | *.bat text eol=crlf -------------------------------------------------------------------------------- /tsconfig.build.json: -------------------------------------------------------------------------------- 1 | 2 | { 3 | "extends": "./tsconfig", 4 | "exclude": ["example"] 5 | } 6 | -------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: ['module:metro-react-native-babel-preset'], 3 | }; 4 | -------------------------------------------------------------------------------- /example/app.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "JsiContactsExample", 3 | "displayName": "JsiContacts Example" 4 | } 5 | -------------------------------------------------------------------------------- /example/ios/File.swift: -------------------------------------------------------------------------------- 1 | // 2 | // File.swift 3 | // JsiContactsExample 4 | // 5 | 6 | import Foundation 7 | -------------------------------------------------------------------------------- /ios/JsiContacts.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface JsiContacts : NSObject 4 | 5 | @end 6 | -------------------------------------------------------------------------------- /.yarnrc: -------------------------------------------------------------------------------- 1 | # Override Yarn command so we can automatically setup the repo on running `yarn` 2 | 3 | yarn-path "scripts/bootstrap.js" 4 | -------------------------------------------------------------------------------- /example/android/app/debug.keystore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrousavy/react-native-jsi-contacts/HEAD/example/android/app/debug.keystore -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | JsiContacts Example 3 | 4 | -------------------------------------------------------------------------------- /example/ios/JsiContactsExample/Images.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /example/ios/JsiContactsExample-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | // 2 | // Use this file to import your target's public headers that you would like to expose to Swift. 3 | // 4 | -------------------------------------------------------------------------------- /android/gradle.properties: -------------------------------------------------------------------------------- 1 | JsiContacts_compileSdkVersion=30 2 | JsiContacts_buildToolsVersion=30.0.2 3 | JsiContacts_targetSdkVersion=30 4 | android.useAndroidX=true 5 | -------------------------------------------------------------------------------- /example/android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrousavy/react-native-jsi-contacts/HEAD/example/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /ios/JsiContacts.mm: -------------------------------------------------------------------------------- 1 | #import "JsiContacts.h" 2 | 3 | @implementation JsiContacts 4 | 5 | RCT_EXPORT_MODULE() 6 | 7 | // TODO: Implement on iOS. 8 | 9 | @end 10 | -------------------------------------------------------------------------------- /android/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrousavy/react-native-jsi-contacts/HEAD/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrousavy/react-native-jsi-contacts/HEAD/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrousavy/react-native-jsi-contacts/HEAD/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrousavy/react-native-jsi-contacts/HEAD/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrousavy/react-native-jsi-contacts/HEAD/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrousavy/react-native-jsi-contacts/HEAD/example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrousavy/react-native-jsi-contacts/HEAD/example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrousavy/react-native-jsi-contacts/HEAD/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrousavy/react-native-jsi-contacts/HEAD/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrousavy/react-native-jsi-contacts/HEAD/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/index.tsx: -------------------------------------------------------------------------------- 1 | import { AppRegistry } from 'react-native'; 2 | import App from './src/App'; 3 | import { name as appName } from './app.json'; 4 | 5 | AppRegistry.registerComponent(appName, () => App); 6 | -------------------------------------------------------------------------------- /example/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.9-all.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /example/ios/JsiContactsExample.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/JsiContactsExample.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /example/android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'JsiContactsExample' 2 | apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings) 3 | include ':app' 4 | 5 | include ':jsicontacts' 6 | project(':jsicontacts').projectDir = new File(rootProject.projectDir, '../../android') 7 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig helps developers define and maintain consistent 2 | # coding styles between different editors and IDEs 3 | # editorconfig.org 4 | 5 | root = true 6 | 7 | [*] 8 | 9 | indent_style = space 10 | indent_size = 2 11 | 12 | end_of_line = lf 13 | charset = utf-8 14 | trim_trailing_whitespace = true 15 | insert_final_newline = true 16 | -------------------------------------------------------------------------------- /example/babel.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const pak = require('../package.json'); 3 | 4 | module.exports = { 5 | presets: ['module:metro-react-native-babel-preset'], 6 | plugins: [ 7 | [ 8 | 'module-resolver', 9 | { 10 | extensions: ['.tsx', '.ts', '.js', '.json'], 11 | alias: { 12 | [pak.name]: path.join(__dirname, '..', pak.source), 13 | }, 14 | }, 15 | ], 16 | ], 17 | }; 18 | -------------------------------------------------------------------------------- /example/ios/JsiContactsExample/AppDelegate.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Facebook, Inc. and its affiliates. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | #import 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (nonatomic, strong) UIWindow *window; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /example/ios/JsiContactsExample/main.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Facebook, Inc. and its affiliates. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | #import 9 | 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /example/android/app/src/main/java/com/example/jsicontacts/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.example.jsicontacts; 2 | 3 | import com.facebook.react.ReactActivity; 4 | 5 | public class MainActivity extends ReactActivity { 6 | 7 | /** 8 | * Returns the name of the main component registered from JavaScript. This is used to schedule 9 | * rendering of the component. 10 | */ 11 | @Override 12 | protected String getMainComponentName() { 13 | return "JsiContactsExample"; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /example/android/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | -------------------------------------------------------------------------------- /example/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /android/src/main/cpp/java-bindings/JHashMap.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Marc Rousavy on 25.06.21. 3 | // 4 | // Copied from https://github.com/mrousavy/react-native-vision-camera/blob/main/android/src/main/cpp/java-bindings/JHashMap.cpp 5 | 6 | #include "JHashMap.h" 7 | 8 | #include 9 | #include 10 | 11 | 12 | namespace facebook { 13 | namespace jni { 14 | 15 | template 16 | local_ref> JHashMap::create() { 17 | return JHashMap::newInstance(); 18 | } 19 | 20 | } // namespace jni 21 | } // namespace facebook 22 | -------------------------------------------------------------------------------- /example/ios/Podfile: -------------------------------------------------------------------------------- 1 | require_relative '../node_modules/react-native/scripts/react_native_pods' 2 | require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules' 3 | 4 | platform :ios, '11.0' 5 | 6 | target 'JsiContactsExample' do 7 | config = use_native_modules! 8 | 9 | use_react_native!( 10 | :path => config[:reactNativePath], 11 | :hermes_enabled => false 12 | ) 13 | 14 | pod 'react-native-jsi-contacts', :path => '../..' 15 | 16 | use_flipper!() 17 | post_install do |installer| 18 | react_native_post_install(installer) 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /android/src/main/cpp/JSIJNIConversion.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Marc Rousavy on 22.06.21. 3 | // 4 | // Copied from https://github.com/mrousavy/react-native-vision-camera/blob/main/android/src/main/cpp/JSIJNIConversion.h 5 | 6 | #pragma once 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | namespace vision { 13 | 14 | namespace JSIJNIConversion { 15 | 16 | using namespace facebook; 17 | 18 | jsi::Value convertJNIObjectToJSIValue(jsi::Runtime& runtime, const jni::local_ref& object); 19 | 20 | } // namespace JSIJNIConversion 21 | 22 | } // namespace vision 23 | -------------------------------------------------------------------------------- /android/src/main/cpp/java-bindings/JArrayList.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Marc Rousavy on 24.06.21. 3 | // 4 | // Copied from https://github.com/mrousavy/react-native-vision-camera/blob/main/android/src/main/cpp/java-bindings/JArrayList.h 5 | 6 | #pragma once 7 | 8 | #include 9 | #include 10 | 11 | namespace vision { 12 | 13 | using namespace facebook; 14 | using namespace jni; 15 | 16 | // TODO: Remove when fbjni 0.2.3 releases. 17 | template 18 | struct JArrayList : JavaClass, JList> { 19 | constexpr static auto kJavaDescriptor = "Ljava/util/ArrayList;"; 20 | }; 21 | 22 | } // namespace vision 23 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: mrousavy 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: mrousavy 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 13 | -------------------------------------------------------------------------------- /android/src/main/cpp/java-bindings/JContactsProvider.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Marc Rousavy on 30.09.21. 3 | // 4 | 5 | #pragma once 6 | 7 | #include 8 | #include 9 | #include 10 | #include "JContact.h" 11 | 12 | namespace mrousavy { 13 | 14 | using namespace facebook; 15 | using namespace jni; 16 | 17 | struct JContactsProvider : public JavaClass { 18 | static constexpr auto kJavaDescriptor = "Lcom/mrousavy/jsi/contacts/ContactsProvider;"; 19 | 20 | public: 21 | local_ref> getContacts() const; 22 | local_ref getHash() const; 23 | }; 24 | 25 | } // namespace vision 26 | -------------------------------------------------------------------------------- /react-native-jsi-contacts.podspec: -------------------------------------------------------------------------------- 1 | require "json" 2 | 3 | package = JSON.parse(File.read(File.join(__dir__, "package.json"))) 4 | 5 | Pod::Spec.new do |s| 6 | s.name = "react-native-jsi-contacts" 7 | s.version = package["version"] 8 | s.summary = package["description"] 9 | s.homepage = package["homepage"] 10 | s.license = package["license"] 11 | s.authors = package["author"] 12 | 13 | s.platforms = { :ios => "10.0" } 14 | s.source = { :git => "https://github.com/mrousavy/react-native-jsi-contacts.git", :tag => "#{s.version}" } 15 | 16 | s.source_files = "ios/**/*.{h,m,mm}", "cpp/**/*.{h,cpp}" 17 | 18 | s.dependency "React-Core" 19 | end 20 | -------------------------------------------------------------------------------- /android/src/main/cpp/java-bindings/JHashMap.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Marc Rousavy on 25.06.21. 3 | // 4 | // Copied from https://github.com/mrousavy/react-native-vision-camera/blob/main/android/src/main/cpp/java-bindings/JHashMap.h 5 | 6 | #pragma once 7 | 8 | #include 9 | #include 10 | 11 | 12 | namespace facebook { 13 | namespace jni { 14 | 15 | // TODO: Remove when fbjni 0.2.3 releases. 16 | template 17 | struct JHashMap : JavaClass, JMap> { 18 | constexpr static auto kJavaDescriptor = "Ljava/util/HashMap;"; 19 | 20 | static local_ref> create(); 21 | }; 22 | 23 | } // namespace jni 24 | } // namespace facebook 25 | -------------------------------------------------------------------------------- /android/src/main/java/com/mrousavy/jsi/contacts/JsiContactsJSIPackage.java: -------------------------------------------------------------------------------- 1 | package com.mrousavy.jsi.contacts; 2 | 3 | import com.facebook.react.bridge.JSIModulePackage; 4 | import com.facebook.react.bridge.JSIModuleSpec; 5 | import com.facebook.react.bridge.JavaScriptContextHolder; 6 | import com.facebook.react.bridge.ReactApplicationContext; 7 | import java.util.Collections; 8 | import java.util.List; 9 | 10 | public class JsiContactsJSIPackage implements JSIModulePackage { 11 | @Override 12 | public List getJSIModules(ReactApplicationContext reactApplicationContext, JavaScriptContextHolder jsContext) { 13 | JsiContactsModule.install(reactApplicationContext); 14 | return Collections.emptyList(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /android/src/main/cpp/ContactHostObject.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Marc Rousavy on 30.09.21. 3 | // 4 | 5 | #pragma once 6 | 7 | #include 8 | #include 9 | #include "java-bindings/JContact.h" 10 | 11 | namespace mrousavy { 12 | using namespace facebook; 13 | 14 | class ContactHostObject : public jsi::HostObject { 15 | public: 16 | ContactHostObject(jni::alias_ref contact): _contact(jni::make_global(contact)) {} 17 | ~ContactHostObject(); 18 | 19 | jsi::Value get(jsi::Runtime &, const jsi::PropNameID &name) override; 20 | 21 | std::vector getPropertyNames(jsi::Runtime &rt) override; 22 | 23 | private: 24 | jni::global_ref _contact; 25 | }; 26 | 27 | } 28 | -------------------------------------------------------------------------------- /android/src/main/cpp/ThreadPool.h: -------------------------------------------------------------------------------- 1 | // Source: https://github.com/progschj/ThreadPool 2 | 3 | #ifndef THREAD_POOL_H 4 | #define THREAD_POOL_H 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | namespace mrousavy { 11 | namespace multithreading { 12 | 13 | class ThreadPool { 14 | public: 15 | ThreadPool(size_t threadCount); 16 | std::future enqueue(std::function task); 17 | ~ThreadPool(); 18 | private: 19 | // need to keep track of threads so we can join them 20 | std::vector workers; 21 | // the task queue 22 | std::queue> tasks; 23 | 24 | // synchronization 25 | std::mutex queue_mutex; 26 | std::condition_variable condition; 27 | bool stop; 28 | }; 29 | 30 | 31 | } 32 | } 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /example/ios/JsiContactsExample/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "baseUrl": "./", 4 | "paths": { 5 | "react-native-jsi-contacts": ["./src/index"] 6 | }, 7 | "allowUnreachableCode": false, 8 | "allowUnusedLabels": false, 9 | "esModuleInterop": true, 10 | "importsNotUsedAsValues": "error", 11 | "forceConsistentCasingInFileNames": true, 12 | "jsx": "react", 13 | "lib": ["esnext"], 14 | "module": "esnext", 15 | "moduleResolution": "node", 16 | "noFallthroughCasesInSwitch": true, 17 | "noImplicitReturns": true, 18 | "noImplicitUseStrict": false, 19 | "noStrictGenericChecks": false, 20 | "noUnusedLocals": true, 21 | "noUnusedParameters": true, 22 | "resolveJsonModule": true, 23 | "skipLibCheck": true, 24 | "strict": true, 25 | "target": "esnext" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /android/src/main/cpp/java-bindings/JContactsProvider.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Marc Rousavy on 30.09.21. 3 | // 4 | 5 | #include "JContactsProvider.h" 6 | 7 | #include 8 | #include 9 | #include "JContact.h" 10 | 11 | namespace mrousavy { 12 | 13 | using namespace facebook; 14 | using namespace jni; 15 | 16 | local_ref> JContactsProvider::getContacts() const { 17 | auto getContactsMethod = getClass()->getMethod()>("getContacts"); 18 | 19 | auto result = getContactsMethod(self()); 20 | return make_local(result); 21 | } 22 | 23 | local_ref JContactsProvider::getHash() const { 24 | auto getHashMethod = getClass()->getMethod("getHash"); 25 | 26 | return getHashMethod(self()); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /example/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-native-jsi-contacts-example", 3 | "description": "Example app for react-native-jsi-contacts", 4 | "version": "0.0.1", 5 | "private": true, 6 | "scripts": { 7 | "android": "react-native run-android", 8 | "ios": "react-native run-ios", 9 | "start": "react-native start" 10 | }, 11 | "dependencies": { 12 | "react": "^17.0.2", 13 | "react-native": "^0.65.1", 14 | "react-native-contacts": "^7.0.2", 15 | "react-native-permissions": "^3.0.5" 16 | }, 17 | "devDependencies": { 18 | "@babel/core": "^7.12.9", 19 | "@babel/runtime": "^7.12.5", 20 | "@react-native-community/eslint-config": "^2.0.0", 21 | "babel-plugin-module-resolver": "^4.1.0", 22 | "eslint": "7.14.0", 23 | "jest": "^26.6.3", 24 | "metro-react-native-babel-preset": "^0.66.0", 25 | "react-native-codegen": "^0.0.7" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /scripts/bootstrap.js: -------------------------------------------------------------------------------- 1 | const os = require('os'); 2 | const path = require('path'); 3 | const child_process = require('child_process'); 4 | 5 | const root = path.resolve(__dirname, '..'); 6 | const args = process.argv.slice(2); 7 | const options = { 8 | cwd: process.cwd(), 9 | env: process.env, 10 | stdio: 'inherit', 11 | encoding: 'utf-8', 12 | }; 13 | 14 | if (os.type() === 'Windows_NT') { 15 | options.shell = true 16 | } 17 | 18 | let result; 19 | 20 | if (process.cwd() !== root || args.length) { 21 | // We're not in the root of the project, or additional arguments were passed 22 | // In this case, forward the command to `yarn` 23 | result = child_process.spawnSync('yarn', args, options); 24 | } else { 25 | // If `yarn` is run without arguments, perform bootstrap 26 | result = child_process.spawnSync('yarn', ['bootstrap'], options); 27 | } 28 | 29 | process.exitCode = result.status; 30 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # OSX 2 | # 3 | .DS_Store 4 | 5 | # XDE 6 | .expo/ 7 | 8 | # VSCode 9 | .vscode/ 10 | jsconfig.json 11 | 12 | # Xcode 13 | # 14 | build/ 15 | *.pbxuser 16 | !default.pbxuser 17 | *.mode1v3 18 | !default.mode1v3 19 | *.mode2v3 20 | !default.mode2v3 21 | *.perspectivev3 22 | !default.perspectivev3 23 | xcuserdata 24 | *.xccheckout 25 | *.moved-aside 26 | DerivedData 27 | *.hmap 28 | *.ipa 29 | *.xcuserstate 30 | project.xcworkspace 31 | 32 | # Android/IJ 33 | # 34 | .classpath 35 | .cxx 36 | .gradle 37 | .idea 38 | .project 39 | .settings 40 | local.properties 41 | android.iml 42 | 43 | # Cocoapods 44 | # 45 | example/ios/Pods 46 | 47 | # node.js 48 | # 49 | node_modules/ 50 | npm-debug.log 51 | yarn-debug.log 52 | yarn-error.log 53 | 54 | # BUCK 55 | buck-out/ 56 | \.buckd/ 57 | android/app/libs 58 | android/keystores/debug.keystore 59 | 60 | # Expo 61 | .expo/* 62 | 63 | # generated by bob 64 | lib/ 65 | -------------------------------------------------------------------------------- /android/src/main/java/com/mrousavy/jsi/contacts/JsiContactsPackage.java: -------------------------------------------------------------------------------- 1 | package com.mrousavy.jsi.contacts; 2 | 3 | import androidx.annotation.NonNull; 4 | 5 | import com.facebook.react.ReactPackage; 6 | import com.facebook.react.bridge.NativeModule; 7 | import com.facebook.react.bridge.ReactApplicationContext; 8 | import com.facebook.react.uimanager.ViewManager; 9 | 10 | import java.util.ArrayList; 11 | import java.util.Collections; 12 | import java.util.List; 13 | 14 | public class JsiContactsPackage implements ReactPackage { 15 | @NonNull 16 | @Override 17 | public List createNativeModules(@NonNull ReactApplicationContext reactContext) { 18 | List modules = new ArrayList<>(); 19 | modules.add(new JsiContactsModule()); 20 | return modules; 21 | } 22 | 23 | @NonNull 24 | @Override 25 | public List createViewManagers(@NonNull ReactApplicationContext reactContext) { 26 | return Collections.emptyList(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /example/android/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true 19 | 20 | android.useAndroidX=true 21 | android.enableJetifier=true 22 | FLIPPER_VERSION=0.93.0 23 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Marc Rousavy 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /example/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 14 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /android/src/main/cpp/JSIContacts.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include "ThreadPool.h" 5 | #include "java-bindings/JContactsProvider.h" 6 | 7 | namespace mrousavy { 8 | 9 | using namespace facebook; 10 | 11 | class JSIContacts : public jsi::HostObject { 12 | public: 13 | explicit JSIContacts(std::shared_ptr callInvoker, 14 | jni::global_ref contactsProvider): 15 | _callInvoker(callInvoker), 16 | _threadPool(2), 17 | _contactsProvider(contactsProvider) {} 18 | 19 | jsi::Value get(jsi::Runtime &, const jsi::PropNameID &name) override; 20 | std::vector getPropertyNames(jsi::Runtime &rt) override; 21 | 22 | private: 23 | std::shared_ptr _callInvoker; 24 | multithreading::ThreadPool _threadPool; 25 | jni::global_ref _contactsProvider; 26 | jsi::Value getContactsAsync(jsi::Runtime& runtime); 27 | jsi::Value getHashAsync(jsi::Runtime& runtime); 28 | }; 29 | 30 | } 31 | -------------------------------------------------------------------------------- /example/metro.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const blacklist = require('metro-config/src/defaults/exclusionList'); 3 | const escape = require('escape-string-regexp'); 4 | const pak = require('../package.json'); 5 | 6 | const root = path.resolve(__dirname, '..'); 7 | 8 | const modules = Object.keys({ 9 | ...pak.peerDependencies, 10 | }); 11 | 12 | module.exports = { 13 | projectRoot: __dirname, 14 | watchFolders: [root], 15 | 16 | // We need to make sure that only one version is loaded for peerDependencies 17 | // So we blacklist them at the root, and alias them to the versions in example's node_modules 18 | resolver: { 19 | blacklistRE: blacklist( 20 | modules.map( 21 | (m) => 22 | new RegExp(`^${escape(path.join(root, 'node_modules', m))}\\/.*$`) 23 | ) 24 | ), 25 | 26 | extraNodeModules: modules.reduce((acc, name) => { 27 | acc[name] = path.join(__dirname, 'node_modules', name); 28 | return acc; 29 | }, {}), 30 | }, 31 | 32 | transformer: { 33 | getTransformOptions: async () => ({ 34 | transform: { 35 | experimentalImportSupport: false, 36 | inlineRequires: true, 37 | }, 38 | }), 39 | }, 40 | }; 41 | -------------------------------------------------------------------------------- /example/android/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | ext { 5 | buildToolsVersion = "30.0.2" 6 | minSdkVersion = 21 7 | compileSdkVersion = 30 8 | targetSdkVersion = 30 9 | ndkVersion = "20.1.5948944" 10 | } 11 | repositories { 12 | google() 13 | mavenCentral() 14 | jcenter() 15 | } 16 | dependencies { 17 | classpath("com.android.tools.build:gradle:4.2.1") 18 | 19 | // NOTE: Do not place your application dependencies here; they belong 20 | // in the individual module build.gradle files 21 | } 22 | } 23 | 24 | allprojects { 25 | repositories { 26 | mavenLocal() 27 | maven { 28 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm 29 | url("$rootDir/../node_modules/react-native/android") 30 | } 31 | maven { 32 | // Android JSC is installed from npm 33 | url("$rootDir/../node_modules/jsc-android/dist") 34 | } 35 | 36 | google() 37 | mavenCentral() 38 | jcenter() 39 | maven { url 'https://www.jitpack.io' } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/index.tsx: -------------------------------------------------------------------------------- 1 | interface JSIContactsInterface { 2 | getContactsAsync(): Promise>; 3 | getHashAsync(): Promise; 4 | } 5 | 6 | // Globally injected JSI Function declarations 7 | declare global { 8 | var JSIContacts: JSIContactsInterface; 9 | } 10 | 11 | export interface Item { 12 | id: string; 13 | label: string; 14 | value: string; 15 | } 16 | 17 | export interface PostalAddress { 18 | label: string; 19 | formattedAddress: string; 20 | street: string; 21 | pobox: string; 22 | neighborhood: string; 23 | city: string; 24 | region: string; 25 | state: string; 26 | postCode: string; 27 | country: string; 28 | } 29 | 30 | export interface InstantMessageAddress { 31 | username: string; 32 | service: string; 33 | } 34 | 35 | export interface Birthday { 36 | day: number; 37 | month: number; 38 | year: number; 39 | } 40 | 41 | export interface Contact { 42 | contactId: string; 43 | displayName: string; 44 | givenName: string; 45 | middleName: string; 46 | familyName: string; 47 | prefix: string; 48 | suffix: string; 49 | company: string; 50 | jobTitle: string; 51 | department: string; 52 | note: string; 53 | urls: Item[]; 54 | instantMessengers: InstantMessageAddress[]; 55 | hasPhoto: boolean; 56 | photoUri: string; 57 | emails: Item[]; 58 | phones: Item[]; 59 | postalAddresses: PostalAddress[]; 60 | birthday: Birthday; 61 | } 62 | 63 | export function getContactsAsync(): Promise< 64 | Record 65 | > { 66 | return JSIContacts.getContactsAsync(); 67 | } 68 | 69 | export function getHashAsync(): Promise { 70 | return JSIContacts.getHashAsync(); 71 | } 72 | -------------------------------------------------------------------------------- /example/ios/JsiContactsExample/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | JsiContacts Example 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | LSRequiresIPhoneOS 26 | 27 | NSAppTransportSecurity 28 | 29 | NSExceptionDomains 30 | 31 | localhost 32 | 33 | NSExceptionAllowsInsecureHTTPLoads 34 | 35 | 36 | 37 | 38 | NSLocationWhenInUseUsageDescription 39 | 40 | UILaunchStoryboardName 41 | LaunchScreen 42 | UIRequiredDeviceCapabilities 43 | 44 | armv7 45 | 46 | UISupportedInterfaceOrientations 47 | 48 | UIInterfaceOrientationPortrait 49 | UIInterfaceOrientationLandscapeLeft 50 | UIInterfaceOrientationLandscapeRight 51 | 52 | UIViewControllerBasedStatusBarAppearance 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /android/src/main/java/com/mrousavy/jsi/contacts/JsiContactsModule.java: -------------------------------------------------------------------------------- 1 | package com.mrousavy.jsi.contacts; 2 | 3 | import android.content.Context; 4 | import android.database.Cursor; 5 | import android.net.Uri; 6 | import android.provider.ContactsContract; 7 | 8 | import androidx.annotation.Keep; 9 | import androidx.annotation.NonNull; 10 | 11 | import com.facebook.proguard.annotations.DoNotStrip; 12 | import com.facebook.react.bridge.JavaScriptContextHolder; 13 | import com.facebook.react.bridge.ReactContext; 14 | import com.facebook.react.bridge.ReactContextBaseJavaModule; 15 | import com.facebook.react.bridge.ReadableArray; 16 | import com.facebook.react.bridge.WritableArray; 17 | import com.facebook.react.bridge.WritableNativeArray; 18 | import com.facebook.react.bridge.WritableNativeMap; 19 | import com.facebook.react.module.annotations.ReactModule; 20 | import com.facebook.react.turbomodule.core.CallInvokerHolderImpl; 21 | 22 | @ReactModule(name = JsiContactsModule.NAME) 23 | public class JsiContactsModule extends ReactContextBaseJavaModule { 24 | public static final String NAME = "JsiContacts"; 25 | static { 26 | System.loadLibrary("jsicontacts"); 27 | } 28 | 29 | @Override 30 | @NonNull 31 | public String getName() { 32 | return NAME; 33 | } 34 | 35 | public static void install(ReactContext context) { 36 | JavaScriptContextHolder jsContext = context.getJavaScriptContextHolder(); 37 | CallInvokerHolderImpl callInvokerHolder = (CallInvokerHolderImpl) context.getCatalystInstance().getJSCallInvokerHolder(); 38 | ContactsProvider contactsProvider = new ContactsProvider(context.getContentResolver()); 39 | 40 | nativeInstall(contactsProvider, jsContext.get(), callInvokerHolder); 41 | } 42 | 43 | private static native void nativeInstall(ContactsProvider contactsProvider, long jsiPtr, CallInvokerHolderImpl callInvoker); 44 | } 45 | -------------------------------------------------------------------------------- /android/src/main/cpp/java-bindings/JContact.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Marc Rousavy on 30.09.21. 3 | // 4 | 5 | #pragma once 6 | 7 | #include 8 | #include 9 | #include 10 | #include "JArrayList.h" 11 | 12 | namespace mrousavy { 13 | 14 | using namespace facebook; 15 | using namespace jni; 16 | using namespace vision; 17 | 18 | struct JContact : public JavaClass { 19 | static constexpr auto kJavaDescriptor = "Lcom/mrousavy/jsi/contacts/Contact;"; 20 | 21 | struct JItem : public JavaClass { 22 | static constexpr auto kJavaDescriptor = "Lcom/mrousavy/jsi/contacts/Contact$Item;"; 23 | 24 | local_ref getLabel(); 25 | local_ref getValue(); 26 | local_ref getId(); 27 | }; 28 | struct JBirthday : public JavaClass { 29 | static constexpr auto kJavaDescriptor = "Lcom/mrousavy/jsi/contacts/Contact$Birthday;"; 30 | 31 | jint getYear(); 32 | jint getMonth(); 33 | jint getDay(); 34 | }; 35 | struct JPostalAddressItem : public JavaClass { 36 | static constexpr auto kJavaDescriptor = "Lcom/mrousavy/jsi/contacts/Contact$PostalAddressItem;"; 37 | }; 38 | 39 | local_ref getContactId(); 40 | local_ref getDisplayName(); 41 | local_ref getGivenName(); 42 | local_ref getMiddleName(); 43 | local_ref getFamilyName(); 44 | local_ref getPrefix(); 45 | local_ref getSuffix(); 46 | local_ref getCompany(); 47 | local_ref getJobTitle(); 48 | local_ref getDepartment(); 49 | local_ref getNote(); 50 | local_ref> getUrls(); 51 | local_ref> getInstantMessengers(); 52 | jboolean getHasPhoto(); 53 | local_ref getPhotoUri(); 54 | local_ref> getEmails(); 55 | local_ref> getPhones(); 56 | local_ref> getPostalAddresses(); 57 | local_ref getBirthday(); 58 | }; 59 | 60 | } // namespace mrousavy 61 | -------------------------------------------------------------------------------- /android/src/main/cpp/ThreadPool.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // ThreadPool.cpp 3 | // Multithreading 4 | // 5 | // Created by Marc Rousavy on 16.03.21. 6 | // Copyright © 2021 Facebook. All rights reserved. 7 | // 8 | 9 | #include "ThreadPool.h" 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | namespace mrousavy { 23 | namespace multithreading { 24 | 25 | // the constructor just launches some amount of workers 26 | ThreadPool::ThreadPool(size_t threads): stop(false) { 27 | for (size_t i = 0; i < threads; ++i) { 28 | workers.emplace_back([this] { 29 | while (true) { 30 | std::function task; 31 | 32 | { 33 | std::unique_lock lock(this->queue_mutex); 34 | this->condition.wait(lock, 35 | [this]{ return this->stop || !this->tasks.empty(); }); 36 | if(this->stop && this->tasks.empty()) 37 | return; 38 | task = std::move(this->tasks.front()); 39 | this->tasks.pop(); 40 | } 41 | 42 | task(); 43 | } 44 | }); 45 | } 46 | } 47 | 48 | // add new work item to the pool 49 | std::future ThreadPool::enqueue(std::function func) { 50 | auto task = std::make_shared>(std::bind(std::forward>(func))); 51 | std::future res = task->get_future(); 52 | 53 | { 54 | std::unique_lock lock(queue_mutex); 55 | 56 | // don't allow enqueueing after stopping the pool 57 | if (stop) 58 | throw std::runtime_error("enqueue on stopped ThreadPool"); 59 | 60 | tasks.emplace([task](){ (*task)(); }); 61 | } 62 | 63 | condition.notify_one(); 64 | return res; 65 | } 66 | 67 | // the destructor joins all threads 68 | ThreadPool::~ThreadPool() { 69 | { 70 | std::unique_lock lock(queue_mutex); 71 | stop = true; 72 | } 73 | condition.notify_all(); 74 | for (auto& worker : workers) { 75 | worker.join(); 76 | } 77 | } 78 | 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /android/src/main/cpp/nativeInstall.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "JSIContacts.h" 7 | #include "java-bindings/JContactsProvider.h" 8 | #include "java-bindings/JContact.h" 9 | 10 | using namespace facebook; 11 | using TCallInvoker = jni::alias_ref; 12 | 13 | void install(jsi::Runtime& jsiRuntime, 14 | std::shared_ptr jsCallInvoker, 15 | jni::global_ref contactsProvider) { 16 | auto contacts = std::make_shared(jsCallInvoker, contactsProvider); 17 | auto hostObject = jsi::Object::createFromHostObject(jsiRuntime, contacts); 18 | jsiRuntime.global().setProperty(jsiRuntime, "JSIContacts", hostObject); 19 | } 20 | 21 | extern "C" 22 | JNIEXPORT void JNICALL 23 | Java_com_mrousavy_jsi_contacts_JsiContactsModule_nativeInstall(JNIEnv *env, 24 | jclass type, 25 | jobject boxedContactsProvider, 26 | jlong jsiRuntimePointer, 27 | jobject boxedCallInvokerHolder) { 28 | auto runtime = reinterpret_cast(jsiRuntimePointer); 29 | 30 | auto boxedCallInvokerRef = jni::make_local(boxedCallInvokerHolder); 31 | auto callInvokerHolder = jni::dynamic_ref_cast(boxedCallInvokerRef); 32 | auto callInvoker = callInvokerHolder->cthis()->getCallInvoker(); 33 | 34 | auto boxedContactsProviderRef = jni::make_global(boxedContactsProvider); 35 | auto contactsProvider = jni::dynamic_ref_cast(boxedContactsProviderRef); 36 | 37 | if (runtime) { 38 | install(*runtime, callInvoker, contactsProvider); 39 | } 40 | // if runtime was nullptr, RNContacts will not be installed. This should only happen while Remote Debugging (Chrome), but will be weird either way. 41 | } 42 | 43 | JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *) { 44 | return facebook::jni::initialize(vm, [] { 45 | }); 46 | } 47 | -------------------------------------------------------------------------------- /example/ios/JsiContactsExample/AppDelegate.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Facebook, Inc. and its affiliates. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | #import "AppDelegate.h" 9 | 10 | #import 11 | #import 12 | #import 13 | 14 | #ifdef FB_SONARKIT_ENABLED 15 | #import 16 | #import 17 | #import 18 | #import 19 | #import 20 | #import 21 | static void InitializeFlipper(UIApplication *application) { 22 | FlipperClient *client = [FlipperClient sharedClient]; 23 | SKDescriptorMapper *layoutDescriptorMapper = [[SKDescriptorMapper alloc] initWithDefaults]; 24 | [client addPlugin:[[FlipperKitLayoutPlugin alloc] initWithRootNode:application withDescriptorMapper:layoutDescriptorMapper]]; 25 | [client addPlugin:[[FKUserDefaultsPlugin alloc] initWithSuiteName:nil]]; 26 | [client addPlugin:[FlipperKitReactPlugin new]]; 27 | [client addPlugin:[[FlipperKitNetworkPlugin alloc] initWithNetworkAdapter:[SKIOSNetworkAdapter new]]]; 28 | [client start]; 29 | } 30 | #endif 31 | 32 | @implementation AppDelegate 33 | 34 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 35 | { 36 | #ifdef FB_SONARKIT_ENABLED 37 | InitializeFlipper(application); 38 | #endif 39 | RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions]; 40 | RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge 41 | moduleName:@"JsiContactsExample" 42 | initialProperties:nil]; 43 | 44 | rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1]; 45 | 46 | self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; 47 | UIViewController *rootViewController = [UIViewController new]; 48 | rootViewController.view = rootView; 49 | self.window.rootViewController = rootViewController; 50 | [self.window makeKeyAndVisible]; 51 | return YES; 52 | } 53 | 54 | - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge 55 | { 56 | #if DEBUG 57 | return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil]; 58 | #else 59 | return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; 60 | #endif 61 | } 62 | 63 | @end 64 | -------------------------------------------------------------------------------- /android/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.9.0) 2 | 3 | set (PACKAGE_NAME "react-native-jsi-contacts") 4 | set (BUILD_DIR ${CMAKE_SOURCE_DIR}/build) 5 | set (CMAKE_CXX_FLAGS "-DFOLLY_NO_CONFIG=1 -DFOLLY_HAVE_CLOCK_GETTIME=1 -DFOLLY_HAVE_MEMRCHR=1 -DFOLLY_USE_LIBCPP=1 -DFOLLY_MOBILE=1 -DON_ANDROID -DONANDROID") 6 | 7 | file (GLOB LIBFBJNI_INCLUDE_DIR "${BUILD_DIR}/fbjni-*-headers.jar/") 8 | 9 | include_directories( 10 | "${LIBFBJNI_INCLUDE_DIR}" 11 | "${BUILD_DIR}/third-party-ndk/boost" 12 | "${BUILD_DIR}/third-party-ndk/double-conversion" 13 | "${BUILD_DIR}/third-party-ndk/folly" 14 | "${BUILD_DIR}/third-party-ndk/glog" 15 | "${NODE_MODULES_DIR}/react-native/React" 16 | "${NODE_MODULES_DIR}/react-native/React/Base" 17 | "${NODE_MODULES_DIR}/react-native/ReactAndroid/src/main/jni" 18 | "${NODE_MODULES_DIR}/react-native/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni" 19 | "${NODE_MODULES_DIR}/react-native/ReactCommon" 20 | "${NODE_MODULES_DIR}/react-native/ReactCommon/callinvoker" 21 | "${NODE_MODULES_DIR}/react-native/ReactCommon/jsi" 22 | ) 23 | 24 | add_library(jsicontacts # <-- Library name 25 | SHARED 26 | src/main/cpp/java-bindings/JContactsProvider.cpp 27 | src/main/cpp/java-bindings/JContact.cpp 28 | src/main/cpp/java-bindings/JHashMap.cpp 29 | src/main/cpp/ThreadPool.cpp 30 | src/main/cpp/nativeInstall.cpp 31 | src/main/cpp/JSIJNIConversion.cpp 32 | src/main/cpp/ContactHostObject.cpp 33 | src/main/cpp/JSIContacts.cpp 34 | ) 35 | 36 | set_target_properties( 37 | jsicontacts PROPERTIES 38 | CXX_STANDARD 17 39 | CXX_EXTENSIONS OFF 40 | POSITION_INDEPENDENT_CODE ON 41 | ) 42 | 43 | file (GLOB LIBRN_DIR "${BUILD_DIR}/react-native-0*/jni/${ANDROID_ABI}") 44 | 45 | find_library( 46 | log-lib 47 | log 48 | ) 49 | find_library( 50 | FBJNI_LIB 51 | fbjni 52 | PATHS ${LIBRN_DIR} 53 | NO_CMAKE_FIND_ROOT_PATH 54 | ) 55 | find_library( 56 | FOLLY_JSON_LIB 57 | folly_json 58 | PATHS ${LIBRN_DIR} 59 | NO_CMAKE_FIND_ROOT_PATH 60 | ) 61 | find_library( 62 | REACT_NATIVE_JNI_LIB 63 | reactnativejni 64 | PATHS ${LIBRN_DIR} 65 | NO_CMAKE_FIND_ROOT_PATH 66 | ) 67 | find_library( 68 | JSI_LIB 69 | jsi 70 | PATHS ${LIBRN_DIR} 71 | NO_CMAKE_FIND_ROOT_PATH 72 | ) 73 | 74 | target_link_libraries( 75 | jsicontacts 76 | ${log-lib} 77 | ${JSI_LIB} 78 | ${REACT_NATIVE_JNI_LIB} 79 | ${FBJNI_LIB} 80 | ${FOLLY_JSON_LIB} 81 | android 82 | ) 83 | -------------------------------------------------------------------------------- /example/src/App.tsx: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | import { StyleSheet, View, Text, Alert, FlatList } from 'react-native'; 3 | import { 4 | Contact, 5 | getContactsAsync, 6 | getHashAsync, 7 | } from 'react-native-jsi-contacts'; 8 | import { getAll } from 'react-native-contacts'; 9 | import { check, PERMISSIONS, request } from 'react-native-permissions'; 10 | 11 | declare global { 12 | var performance: { 13 | now: () => number; 14 | }; 15 | } 16 | 17 | async function runBenchmark() { 18 | { 19 | console.log(`[JSI] Begin Benchmark..`); 20 | const begin = global.performance.now(); 21 | const contacts = await getContactsAsync(); 22 | const end = global.performance.now(); 23 | const arr = Object.keys(contacts).map((key) => contacts[key]); 24 | console.log(`[JSI] Got ${arr.length} contacts in ${end - begin}ms.`); 25 | } 26 | 27 | { 28 | console.log(`[Bridge] Begin Benchmark..`); 29 | const begin = global.performance.now(); 30 | const contacts = await getAll(); 31 | const end = global.performance.now(); 32 | console.log( 33 | `[Bridge] Got ${contacts.length} contacts in ${end - begin}ms.` 34 | ); 35 | } 36 | 37 | { 38 | console.log(`[JSI] Getting Contacts Hash...`); 39 | const begin = global.performance.now(); 40 | const hash = await getHashAsync(); 41 | const end = global.performance.now(); 42 | console.log(`[JSI] Got contacts hash: ${hash} in ${end - begin}ms.`); 43 | } 44 | } 45 | 46 | export default function App() { 47 | const [result, setResult] = React.useState([]); 48 | 49 | const load = React.useCallback(async () => { 50 | const permission = await check(PERMISSIONS.ANDROID.READ_CONTACTS); 51 | if (permission !== 'granted') { 52 | const requestResult = await request(PERMISSIONS.ANDROID.READ_CONTACTS); 53 | if (requestResult !== 'granted') { 54 | Alert.alert( 55 | 'Permission denied!', 56 | 'Permission to access contacts has been denied.' 57 | ); 58 | } 59 | } 60 | 61 | console.log(`JSI: Contacts Permission: ${permission}`); 62 | const contacts = await getContactsAsync(); 63 | const arr = Object.keys(contacts).map((key) => contacts[key]); 64 | setResult(arr); 65 | 66 | setTimeout(runBenchmark, 2000); 67 | }, []); 68 | 69 | React.useEffect(() => { 70 | load(); 71 | }, [load]); 72 | 73 | return ( 74 | 75 | contact.contactId} 78 | renderItem={({ item }) => ( 79 | {item.displayName} 80 | )} 81 | /> 82 | 83 | ); 84 | } 85 | 86 | const styles = StyleSheet.create({ 87 | container: { 88 | flex: 1, 89 | alignItems: 'center', 90 | justifyContent: 'center', 91 | paddingVertical: 20, 92 | }, 93 | box: { 94 | width: 60, 95 | height: 60, 96 | marginVertical: 20, 97 | }, 98 | }); 99 | -------------------------------------------------------------------------------- /example/android/app/src/main/java/com/example/jsicontacts/MainApplication.java: -------------------------------------------------------------------------------- 1 | package com.example.jsicontacts; 2 | 3 | import android.app.Application; 4 | import android.content.Context; 5 | 6 | import androidx.annotation.Nullable; 7 | 8 | import com.facebook.react.PackageList; 9 | import com.facebook.react.ReactApplication; 10 | import com.facebook.react.ReactNativeHost; 11 | import com.facebook.react.ReactPackage; 12 | import com.facebook.react.ReactInstanceManager; 13 | import com.facebook.react.bridge.JSIModulePackage; 14 | import com.facebook.soloader.SoLoader; 15 | import com.mrousavy.jsi.contacts.JsiContactsJSIPackage; 16 | 17 | import java.lang.reflect.InvocationTargetException; 18 | import java.util.List; 19 | 20 | public class MainApplication extends Application implements ReactApplication { 21 | 22 | private final ReactNativeHost mReactNativeHost = 23 | new ReactNativeHost(this) { 24 | @Override 25 | public boolean getUseDeveloperSupport() { 26 | return BuildConfig.DEBUG; 27 | } 28 | 29 | @Override 30 | protected List getPackages() { 31 | @SuppressWarnings("UnnecessaryLocalVariable") 32 | List packages = new PackageList(this).getPackages(); 33 | // Packages that cannot be autolinked yet can be added manually here, for JsiContactsExample: 34 | // packages.add(new MyReactNativePackage()); 35 | return packages; 36 | } 37 | 38 | @Nullable 39 | @Override 40 | protected JSIModulePackage getJSIModulePackage() { 41 | return new JsiContactsJSIPackage(); 42 | } 43 | 44 | @Override 45 | protected String getJSMainModuleName() { 46 | return "index"; 47 | } 48 | }; 49 | 50 | @Override 51 | public ReactNativeHost getReactNativeHost() { 52 | return mReactNativeHost; 53 | } 54 | 55 | @Override 56 | public void onCreate() { 57 | super.onCreate(); 58 | SoLoader.init(this, /* native exopackage */ false); 59 | initializeFlipper(this, getReactNativeHost().getReactInstanceManager()); // Remove this line if you don't want Flipper enabled 60 | } 61 | 62 | /** 63 | * Loads Flipper in React Native templates. 64 | * 65 | * @param context 66 | */ 67 | private static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) { 68 | if (BuildConfig.DEBUG) { 69 | try { 70 | /* 71 | We use reflection here to pick up the class that initializes Flipper, 72 | since Flipper library is not available in release mode 73 | */ 74 | Class aClass = Class.forName("com.example.jsicontacts.ReactNativeFlipper"); 75 | aClass 76 | .getMethod("initializeFlipper", Context.class, ReactInstanceManager.class) 77 | .invoke(null, context, reactInstanceManager); 78 | } catch (ClassNotFoundException e) { 79 | e.printStackTrace(); 80 | } catch (NoSuchMethodException e) { 81 | e.printStackTrace(); 82 | } catch (IllegalAccessException e) { 83 | e.printStackTrace(); 84 | } catch (InvocationTargetException e) { 85 | e.printStackTrace(); 86 | } 87 | } 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # react-native-jsi-contacts 2 | 3 | The current **react-native-contacts** library uses the _React Native Bridge_ to convert the native Java/Objective-C types to JavaScript values. This is asynchronous, batched, and serializes the huge contacts list in the native world (write into `WritableArray`/`WritableMap`, then let the Bridge convert to JSON), then deserializes it on the JavaScript side using JSON. It is therefore slow. 4 | 5 | react-native-jsi-contacts uses JSI to be way faster. 6 | 7 | * Direct invocation (no batching!) 8 | * No JSON serialization happening 9 | * Directly convert object into JSI Types 10 | * Lazily get individual Contact fields (`jsi::HostObject` lazy-get) 11 | 12 | > ⚠️ react-native-jsi-contacts only works on Android. If you want me to implement iOS support, consider funding the project. 13 | 14 | ## Performance 15 | 16 | The library uses almost the same native "`getContacts()`" function as [react-native-contacts](https://github.com/morenoh149/react-native-contacts) (minor tweaks to not use the Bridge types `WritableArray`/`WritableMap`), so the only difference is the conversion speed. 17 | 18 | For 25 contacts, I have measured an average speed increase of ~35%, this greatly scales with the amount of contacts you have though. 19 | 20 | ``` 21 | LOG JSI: Contacts Permission: granted 22 | LOG JSI: Got: 25 contacts in 55.14947900176048ms. 23 | LOG Bridge: Contacts Permission: granted 24 | LOG Bridge: Got: 25 contacts in 74.15260401368141ms. 25 | ``` 26 | 27 | > For 25 contacts, the conversion between the native Java Contacts list and the JavaScript Contacts list takes only ~3 milliseconds! 28 | 29 | ## Installation 30 | 31 | 1. Install using npm/yarn 32 | ```sh 33 | npm install react-native-jsi-contacts 34 | ``` 35 | 36 | 2. Add this code: 37 | 38 | ```java 39 | JsiContactsModule.install(reactApplicationContext); 40 | ``` 41 | 42 | to your `JSIModulePackage`'s `getJSIModules` method. See [the react-native-mmkv installation guide](https://github.com/mrousavy/react-native-mmkv/blob/master/INSTALL.md) on how to create a `JSIModulePackage`. 43 | 44 | ## Sponsors 45 | 46 | 47 | 48 | This project is sponsored by [Galaxycard](https://www.galaxycard.in). 49 | 50 | ## Usage 51 | 52 | Get a list of all contacts: 53 | 54 | ```js 55 | import { getContactsAsync } from "react-native-jsi-contacts"; 56 | 57 | const contacts = await getContactsAsync(); 58 | ``` 59 | 60 | Get a hashsum to compare for any changes in the contact book: 61 | 62 | ```js 63 | import { getHashAsync } from "react-native-jsi-contacts"; 64 | import { MMKV } from "react-native-mmkv"; 65 | 66 | const storage = new MMKV(); 67 | 68 | const hash = await getHashAsync(); 69 | const previousHash = storage.getString("contactsHash") 70 | if (previousHash !== hash) { 71 | // get all contacts and reload hash now. 72 | } 73 | ``` 74 | 75 | ## Contributing 76 | 77 | See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow. 78 | 79 | ## License 80 | 81 | MIT 82 | 83 | ## Thanks 84 | 85 | * Thanks to GalaxyCard for sponsoring this project 86 | * Thanks to react-native-contacts for the native "`getContacts()`" implementation 87 | -------------------------------------------------------------------------------- /example/android/gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem http://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto init 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto init 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :init 68 | @rem Get command-line arguments, handling Windows variants 69 | 70 | if not "%OS%" == "Windows_NT" goto win9xME_args 71 | 72 | :win9xME_args 73 | @rem Slurp the command line arguments. 74 | set CMD_LINE_ARGS= 75 | set _SKIP=2 76 | 77 | :win9xME_args_slurp 78 | if "x%~1" == "x" goto execute 79 | 80 | set CMD_LINE_ARGS=%* 81 | 82 | :execute 83 | @rem Setup the command line 84 | 85 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 86 | 87 | @rem Execute Gradle 88 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 89 | 90 | :end 91 | @rem End local scope for the variables with windows NT shell 92 | if "%ERRORLEVEL%"=="0" goto mainEnd 93 | 94 | :fail 95 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 96 | rem the _cmd.exe /c_ return code! 97 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 98 | exit /b 1 99 | 100 | :mainEnd 101 | if "%OS%"=="Windows_NT" endlocal 102 | 103 | :omega 104 | -------------------------------------------------------------------------------- /example/android/app/src/debug/java/com/example/reactnativejsicontacts/ReactNativeFlipper.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Facebook, Inc. and its affiliates. 3 | * 4 | *

This source code is licensed under the MIT license found in the LICENSE file in the root 5 | * directory of this source tree. 6 | */ 7 | package com.example.jsicontacts; 8 | 9 | import android.content.Context; 10 | import com.facebook.flipper.android.AndroidFlipperClient; 11 | import com.facebook.flipper.android.utils.FlipperUtils; 12 | import com.facebook.flipper.core.FlipperClient; 13 | import com.facebook.flipper.plugins.crashreporter.CrashReporterPlugin; 14 | import com.facebook.flipper.plugins.databases.DatabasesFlipperPlugin; 15 | import com.facebook.flipper.plugins.fresco.FrescoFlipperPlugin; 16 | import com.facebook.flipper.plugins.inspector.DescriptorMapping; 17 | import com.facebook.flipper.plugins.inspector.InspectorFlipperPlugin; 18 | import com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor; 19 | import com.facebook.flipper.plugins.network.NetworkFlipperPlugin; 20 | import com.facebook.flipper.plugins.react.ReactFlipperPlugin; 21 | import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin; 22 | import com.facebook.react.ReactInstanceManager; 23 | import com.facebook.react.bridge.ReactContext; 24 | import com.facebook.react.modules.network.NetworkingModule; 25 | import okhttp3.OkHttpClient; 26 | 27 | public class ReactNativeFlipper { 28 | public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) { 29 | if (FlipperUtils.shouldEnableFlipper(context)) { 30 | final FlipperClient client = AndroidFlipperClient.getInstance(context); 31 | client.addPlugin(new InspectorFlipperPlugin(context, DescriptorMapping.withDefaults())); 32 | client.addPlugin(new ReactFlipperPlugin()); 33 | client.addPlugin(new DatabasesFlipperPlugin(context)); 34 | client.addPlugin(new SharedPreferencesFlipperPlugin(context)); 35 | client.addPlugin(CrashReporterPlugin.getInstance()); 36 | NetworkFlipperPlugin networkFlipperPlugin = new NetworkFlipperPlugin(); 37 | NetworkingModule.setCustomClientBuilder( 38 | new NetworkingModule.CustomClientBuilder() { 39 | @Override 40 | public void apply(OkHttpClient.Builder builder) { 41 | builder.addNetworkInterceptor(new FlipperOkhttpInterceptor(networkFlipperPlugin)); 42 | } 43 | }); 44 | client.addPlugin(networkFlipperPlugin); 45 | client.start(); 46 | // Fresco Plugin needs to ensure that ImagePipelineFactory is initialized 47 | // Hence we run if after all native modules have been initialized 48 | ReactContext reactContext = reactInstanceManager.getCurrentReactContext(); 49 | if (reactContext == null) { 50 | reactInstanceManager.addReactInstanceEventListener( 51 | new ReactInstanceManager.ReactInstanceEventListener() { 52 | @Override 53 | public void onReactContextInitialized(ReactContext reactContext) { 54 | reactInstanceManager.removeReactInstanceEventListener(this); 55 | reactContext.runOnNativeModulesQueueThread( 56 | new Runnable() { 57 | @Override 58 | public void run() { 59 | client.addPlugin(new FrescoFlipperPlugin()); 60 | } 61 | }); 62 | } 63 | }); 64 | } else { 65 | client.addPlugin(new FrescoFlipperPlugin()); 66 | } 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-native-jsi-contacts", 3 | "version": "0.2.3", 4 | "description": "A contacts library for React Native using JSI", 5 | "main": "lib/commonjs/index.js", 6 | "module": "lib/module/index.js", 7 | "types": "lib/typescript/src/index.d.ts", 8 | "react-native": "src/index.tsx", 9 | "source": "src/index", 10 | "files": [ 11 | "src", 12 | "lib", 13 | "android/src", 14 | "android/build.gradle", 15 | "android/CMakeLists.txt", 16 | "android/gradle.properties", 17 | "ios", 18 | "react-native-jsi-contacts.podspec" 19 | ], 20 | "scripts": { 21 | "test": "jest", 22 | "typescript": "tsc --noEmit", 23 | "lint": "eslint \"**/*.{js,ts,tsx}\"", 24 | "prepare": "bob build", 25 | "release": "release-it", 26 | "example": "yarn --cwd example", 27 | "pods": "cd example && pod-install --quiet", 28 | "bootstrap": "yarn example && yarn && yarn pods" 29 | }, 30 | "keywords": [ 31 | "react-native", 32 | "ios", 33 | "android", 34 | "jsi", 35 | "contacts", 36 | "library" 37 | ], 38 | "repository": "https://github.com/mrousavy/react-native-jsi-contacts", 39 | "author": "Marc Rousavy (https://github.com/mrousavy)", 40 | "license": "MIT", 41 | "bugs": { 42 | "url": "https://github.com/mrousavy/react-native-jsi-contacts/issues" 43 | }, 44 | "homepage": "https://github.com/mrousavy/react-native-jsi-contacts#readme", 45 | "publishConfig": { 46 | "registry": "https://registry.npmjs.org/" 47 | }, 48 | "devDependencies": { 49 | "@react-native-community/eslint-config": "^2.0.0", 50 | "@release-it/conventional-changelog": "^2.0.0", 51 | "@types/jest": "^26.0.0", 52 | "@types/react": "^16.9.19", 53 | "@types/react-native": "0.62.13", 54 | "eslint": "^7.2.0", 55 | "eslint-config-prettier": "^7.0.0", 56 | "eslint-plugin-prettier": "^3.1.3", 57 | "pod-install": "^0.1.0", 58 | "prettier": "^2.0.5", 59 | "react": "^17.0.2", 60 | "react-native": "^0.65.1", 61 | "react-native-builder-bob": "^0.18.2", 62 | "release-it": "^14.2.2", 63 | "typescript": "^4.1.3" 64 | }, 65 | "peerDependencies": { 66 | "react": "*", 67 | "react-native": "*" 68 | }, 69 | "release-it": { 70 | "git": { 71 | "commitMessage": "chore: release ${version}", 72 | "tagName": "v${version}" 73 | }, 74 | "npm": { 75 | "publish": true 76 | }, 77 | "github": { 78 | "release": true 79 | }, 80 | "plugins": { 81 | "@release-it/conventional-changelog": { 82 | "preset": "angular" 83 | } 84 | } 85 | }, 86 | "eslintConfig": { 87 | "root": true, 88 | "extends": [ 89 | "@react-native-community", 90 | "prettier" 91 | ], 92 | "rules": { 93 | "prettier/prettier": [ 94 | "error", 95 | { 96 | "quoteProps": "consistent", 97 | "singleQuote": true, 98 | "tabWidth": 2, 99 | "trailingComma": "es5", 100 | "useTabs": false 101 | } 102 | ] 103 | } 104 | }, 105 | "eslintIgnore": [ 106 | "node_modules/", 107 | "lib/" 108 | ], 109 | "prettier": { 110 | "quoteProps": "consistent", 111 | "singleQuote": true, 112 | "tabWidth": 2, 113 | "trailingComma": "es5", 114 | "useTabs": false 115 | }, 116 | "react-native-builder-bob": { 117 | "source": "src", 118 | "output": "lib", 119 | "targets": [ 120 | "commonjs", 121 | "module", 122 | "typescript" 123 | ] 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /example/ios/JsiContactsExample.xcodeproj/xcshareddata/xcschemes/JsiContactsExample.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 38 | 39 | 44 | 45 | 51 | 52 | 53 | 54 | 64 | 66 | 72 | 73 | 74 | 75 | 81 | 83 | 89 | 90 | 91 | 92 | 94 | 95 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /android/src/main/cpp/java-bindings/JContact.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Marc Rousavy on 30.09.21. 3 | // 4 | 5 | #include "JContact.h" 6 | #include 7 | #include 8 | #include "JArrayList.h" 9 | 10 | namespace mrousavy { 11 | 12 | using namespace facebook; 13 | using namespace jni; 14 | using namespace vision; 15 | 16 | local_ref JContact::getContactId() { 17 | auto field = getClass()->getField("contactId"); 18 | return getFieldValue(field); 19 | } 20 | 21 | local_ref JContact::getDisplayName() { 22 | auto field = getClass()->getField("displayName"); 23 | return getFieldValue(field); 24 | } 25 | 26 | local_ref JContact::getGivenName() { 27 | auto field = getClass()->getField("givenName"); 28 | return getFieldValue(field); 29 | } 30 | 31 | local_ref JContact::getMiddleName() { 32 | auto field = getClass()->getField("middleName"); 33 | return getFieldValue(field); 34 | } 35 | 36 | local_ref JContact::getFamilyName() { 37 | auto field = getClass()->getField("familyName"); 38 | return getFieldValue(field); 39 | } 40 | 41 | local_ref JContact::getPrefix() { 42 | auto field = getClass()->getField("prefix"); 43 | return getFieldValue(field); 44 | } 45 | 46 | local_ref JContact::getSuffix() { 47 | auto field = getClass()->getField("suffix"); 48 | return getFieldValue(field); 49 | } 50 | 51 | local_ref JContact::getCompany() { 52 | auto field = getClass()->getField("company"); 53 | return getFieldValue(field); 54 | } 55 | 56 | local_ref JContact::getJobTitle() { 57 | auto field = getClass()->getField("jobTitle"); 58 | return getFieldValue(field); 59 | } 60 | 61 | local_ref JContact::getDepartment() { 62 | auto field = getClass()->getField("department"); 63 | return getFieldValue(field); 64 | } 65 | 66 | local_ref JContact::getNote() { 67 | auto field = getClass()->getField("note"); 68 | return getFieldValue(field); 69 | } 70 | 71 | local_ref> JContact::getUrls() { 72 | auto field = getClass()->getField>("urls"); 73 | return getFieldValue(field); 74 | } 75 | 76 | local_ref> JContact::getInstantMessengers() { 77 | auto field = getClass()->getField>("instantMessengers"); 78 | return getFieldValue(field); 79 | } 80 | 81 | jboolean JContact::getHasPhoto() { 82 | auto field = getClass()->getField("hasPhoto"); 83 | return getFieldValue(field); 84 | } 85 | 86 | local_ref JContact::getPhotoUri() { 87 | auto field = getClass()->getField("photoUri"); 88 | return getFieldValue(field); 89 | } 90 | 91 | local_ref> JContact::getEmails() { 92 | auto field = getClass()->getField>("emails"); 93 | return getFieldValue(field); 94 | } 95 | 96 | local_ref> JContact::getPhones() { 97 | auto field = getClass()->getField>("phones"); 98 | return getFieldValue(field); 99 | } 100 | 101 | local_ref> JContact::getPostalAddresses() { 102 | auto field = getClass()->getField>("postalAddresses"); 103 | return getFieldValue(field); 104 | } 105 | 106 | local_ref JContact::getBirthday() { 107 | auto field = getClass()->getField("birthday"); 108 | return getFieldValue(field); 109 | } 110 | 111 | 112 | // JItem 113 | local_ref JContact::JItem::getId() { 114 | auto field = getClass()->getField("id"); 115 | return getFieldValue(field); 116 | } 117 | local_ref JContact::JItem::getLabel() { 118 | auto field = getClass()->getField("label"); 119 | return getFieldValue(field); 120 | } 121 | local_ref JContact::JItem::getValue() { 122 | auto field = getClass()->getField("value"); 123 | return getFieldValue(field); 124 | } 125 | 126 | 127 | // JBirthday 128 | jint JContact::JBirthday::getYear() { 129 | auto field = getClass()->getField("year"); 130 | return getFieldValue(field); 131 | } 132 | jint JContact::JBirthday::getMonth() { 133 | auto field = getClass()->getField("month"); 134 | return getFieldValue(field); 135 | } 136 | jint JContact::JBirthday::getDay() { 137 | auto field = getClass()->getField("day"); 138 | return getFieldValue(field); 139 | } 140 | 141 | } 142 | -------------------------------------------------------------------------------- /android/src/main/java/com/mrousavy/jsi/contacts/Contact.java: -------------------------------------------------------------------------------- 1 | package com.mrousavy.jsi.contacts; 2 | 3 | import android.database.Cursor; 4 | import android.provider.ContactsContract; 5 | import android.text.TextUtils; 6 | 7 | import com.facebook.jni.HybridData; 8 | import com.facebook.proguard.annotations.DoNotStrip; 9 | import com.facebook.react.bridge.Arguments; 10 | import com.facebook.react.bridge.WritableMap; 11 | 12 | import java.util.ArrayList; 13 | import java.util.HashMap; 14 | import java.util.List; 15 | import java.util.Map; 16 | 17 | import static android.provider.ContactsContract.CommonDataKinds.Contactables; 18 | import static android.provider.ContactsContract.CommonDataKinds.Email; 19 | import static android.provider.ContactsContract.CommonDataKinds.Event; 20 | import static android.provider.ContactsContract.CommonDataKinds.Organization; 21 | import static android.provider.ContactsContract.CommonDataKinds.Phone; 22 | import static android.provider.ContactsContract.CommonDataKinds.StructuredName; 23 | import static android.provider.ContactsContract.CommonDataKinds.Note; 24 | import static android.provider.ContactsContract.CommonDataKinds.Website; 25 | import static android.provider.ContactsContract.CommonDataKinds.Im; 26 | import static android.provider.ContactsContract.CommonDataKinds.StructuredPostal; 27 | 28 | @DoNotStrip 29 | public class Contact { 30 | @DoNotStrip 31 | public String contactId; 32 | @DoNotStrip 33 | public String rawContactId; 34 | @DoNotStrip 35 | public String displayName; 36 | @DoNotStrip 37 | public String givenName = ""; 38 | @DoNotStrip 39 | public String middleName = ""; 40 | @DoNotStrip 41 | public String familyName = ""; 42 | @DoNotStrip 43 | public String prefix = ""; 44 | @DoNotStrip 45 | public String suffix = ""; 46 | @DoNotStrip 47 | public String company = ""; 48 | @DoNotStrip 49 | public String jobTitle = ""; 50 | @DoNotStrip 51 | public String department = ""; 52 | @DoNotStrip 53 | public String note =""; 54 | @DoNotStrip 55 | public ArrayList urls = new ArrayList<>(); 56 | @DoNotStrip 57 | public ArrayList instantMessengers = new ArrayList<>(); 58 | @DoNotStrip 59 | public boolean hasPhoto = false; 60 | @DoNotStrip 61 | public String photoUri; 62 | @DoNotStrip 63 | public ArrayList emails = new ArrayList<>(); 64 | @DoNotStrip 65 | public ArrayList phones = new ArrayList<>(); 66 | @DoNotStrip 67 | public ArrayList> postalAddresses = new ArrayList<>(); 68 | @DoNotStrip 69 | public Birthday birthday; 70 | 71 | public Contact(String contactId) { 72 | this.contactId = contactId; 73 | } 74 | 75 | @DoNotStrip 76 | public static class Item { 77 | @DoNotStrip 78 | public String label; 79 | @DoNotStrip 80 | public String value; 81 | @DoNotStrip 82 | public String id; 83 | 84 | public Item(String label, String value, String id) { 85 | this.id = id; 86 | this.label = label; 87 | this.value = value; 88 | } 89 | 90 | public Item(String label, String value) { 91 | this.label = label; 92 | this.value = value; 93 | } 94 | } 95 | 96 | @DoNotStrip 97 | public static class Birthday { 98 | @DoNotStrip 99 | public int year = 0; 100 | @DoNotStrip 101 | public int month = 0; 102 | @DoNotStrip 103 | public int day = 0; 104 | 105 | public Birthday(int year, int month, int day) { 106 | this.year = year; 107 | this.month = month; 108 | this.day = day; 109 | } 110 | 111 | public Birthday(int month, int day) { 112 | this.month = month; 113 | this.day = day; 114 | } 115 | } 116 | 117 | @DoNotStrip 118 | public static class PostalAddress { 119 | public static HashMap postalAddressFromCursor(Cursor cursor) { 120 | HashMap map = new HashMap<>(); 121 | map.put("label", getLabel(cursor)); 122 | putString(map, cursor, "formattedAddress", StructuredPostal.FORMATTED_ADDRESS); 123 | putString(map, cursor, "street", StructuredPostal.STREET); 124 | putString(map, cursor, "pobox", StructuredPostal.POBOX); 125 | putString(map, cursor, "neighborhood", StructuredPostal.NEIGHBORHOOD); 126 | putString(map, cursor, "city", StructuredPostal.CITY); 127 | putString(map, cursor, "region", StructuredPostal.REGION); 128 | putString(map, cursor, "state", StructuredPostal.REGION); 129 | putString(map, cursor, "postCode", StructuredPostal.POSTCODE); 130 | putString(map, cursor, "country", StructuredPostal.COUNTRY); 131 | return map; 132 | } 133 | 134 | private static void putString(HashMap map, Cursor cursor, String key, String androidKey) { 135 | final String value = cursor.getString(cursor.getColumnIndex(androidKey)); 136 | if (!TextUtils.isEmpty(value)) 137 | map.put(key, value); 138 | } 139 | 140 | private static String getLabel(Cursor cursor) { 141 | switch (cursor.getInt(cursor.getColumnIndex(StructuredPostal.TYPE))) { 142 | case StructuredPostal.TYPE_HOME: 143 | return "home"; 144 | case StructuredPostal.TYPE_WORK: 145 | return "work"; 146 | case StructuredPostal.TYPE_CUSTOM: 147 | final String label = cursor.getString(cursor.getColumnIndex(StructuredPostal.LABEL)); 148 | return label != null ? label : ""; 149 | } 150 | return "other"; 151 | } 152 | } 153 | } 154 | -------------------------------------------------------------------------------- /example/ios/JsiContactsExample/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 25 | 31 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /android/src/main/cpp/JSIJNIConversion.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Marc Rousavy on 22.06.21. 3 | // 4 | // Copied from https://github.com/mrousavy/react-native-vision-camera/blob/main/android/src/main/cpp/JSIJNIConversion.cpp 5 | 6 | #include "JSIJNIConversion.h" 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include 14 | #include 15 | 16 | #include 17 | #include 18 | #include 19 | 20 | #include 21 | #include 22 | 23 | #include "java-bindings/JArrayList.h" 24 | #include "java-bindings/JHashMap.h" 25 | #include "java-bindings/JContact.h" 26 | #include "ContactHostObject.h" 27 | 28 | namespace vision { 29 | 30 | using namespace facebook; 31 | 32 | jsi::Value JSIJNIConversion::convertJNIObjectToJSIValue(jsi::Runtime &runtime, const jni::local_ref& object) { 33 | if (object == nullptr) { 34 | // null 35 | 36 | return jsi::Value::undefined(); 37 | 38 | } else if (object->isInstanceOf(jni::JBoolean::javaClassStatic())) { 39 | // Boolean 40 | 41 | static const auto getBooleanFunc = jni::findClassLocal("java/lang/Boolean")->getMethod("booleanValue"); 42 | auto boolean = getBooleanFunc(object.get()); 43 | return jsi::Value(boolean == true); 44 | 45 | } else if (object->isInstanceOf(jni::JDouble::javaClassStatic())) { 46 | // Double 47 | 48 | static const auto getDoubleFunc = jni::findClassLocal("java/lang/Double")->getMethod("doubleValue"); 49 | auto d = getDoubleFunc(object.get()); 50 | return jsi::Value(d); 51 | 52 | } else if (object->isInstanceOf(jni::JInteger::javaClassStatic())) { 53 | // Integer 54 | 55 | static const auto getIntegerFunc = jni::findClassLocal("java/lang/Integer")->getMethod("intValue"); 56 | auto i = getIntegerFunc(object.get()); 57 | return jsi::Value(i); 58 | 59 | } else if (object->isInstanceOf(jni::JString::javaClassStatic())) { 60 | // String 61 | 62 | return jsi::String::createFromUtf8(runtime, object->toString()); 63 | 64 | } else if (object->isInstanceOf(mrousavy::JContact::javaClassStatic())) { 65 | // Contact 66 | 67 | auto contact = static_ref_cast(object); 68 | auto hostObject = std::make_shared(contact); 69 | return jsi::Object::createFromHostObject(runtime, hostObject); 70 | 71 | } else if (object->isInstanceOf(mrousavy::JContact::JItem::javaClassStatic())) { 72 | // Contact.Item 73 | 74 | auto item = static_ref_cast(object); 75 | 76 | jsi::Object result(runtime); 77 | result.setProperty(runtime, "id", convertJNIObjectToJSIValue(runtime, item->getId())); 78 | result.setProperty(runtime, "label", convertJNIObjectToJSIValue(runtime, item->getLabel())); 79 | result.setProperty(runtime, "value", convertJNIObjectToJSIValue(runtime, item->getValue())); 80 | return result; 81 | 82 | } else if (object->isInstanceOf(mrousavy::JContact::JBirthday::javaClassStatic())) { 83 | // Contact.Birthday 84 | 85 | auto birthday = static_ref_cast(object); 86 | 87 | jsi::Object result(runtime); 88 | result.setProperty(runtime, "year", jsi::Value(birthday->getYear())); 89 | result.setProperty(runtime, "month", jsi::Value(birthday->getMonth())); 90 | result.setProperty(runtime, "day", jsi::Value(birthday->getDay())); 91 | return result; 92 | 93 | } else if (object->isInstanceOf(JArrayList::javaClassStatic())) { 94 | // ArrayList 95 | 96 | auto arrayList = static_ref_cast>(object); 97 | auto size = arrayList->size(); 98 | 99 | auto result = jsi::Array(runtime, size); 100 | size_t i = 0; 101 | for (const auto& item : *arrayList) { 102 | result.setValueAtIndex(runtime, i, convertJNIObjectToJSIValue(runtime, item)); 103 | i++; 104 | } 105 | return result; 106 | 107 | } else if (object->isInstanceOf(react::ReadableArray::javaClassStatic())) { 108 | // ReadableArray 109 | 110 | static const auto toArrayListFunc = react::ReadableArray::javaClassLocal()->getMethod()>("toArrayList"); 111 | 112 | // call recursive, this time ArrayList 113 | auto array = toArrayListFunc(object.get()); 114 | return convertJNIObjectToJSIValue(runtime, array); 115 | 116 | } else if (object->isInstanceOf(jni::JHashMap::javaClassStatic())) { 117 | // HashMap 118 | 119 | auto map = static_ref_cast>(object); 120 | 121 | auto result = jsi::Object(runtime); 122 | for (const auto& entry : *map) { 123 | auto key = entry.first->toString(); 124 | auto value = entry.second; 125 | if (!value) continue; 126 | 127 | auto jsiValue = convertJNIObjectToJSIValue(runtime, value); 128 | result.setProperty(runtime, key.c_str(), jsiValue); 129 | } 130 | return result; 131 | 132 | } else if (object->isInstanceOf(react::ReadableMap::javaClassStatic())) { 133 | // ReadableMap 134 | 135 | static const auto toHashMapFunc = react::ReadableMap::javaClassLocal()->getMethod()>("toHashMap"); 136 | 137 | // call recursive, this time HashMap 138 | auto hashMap = toHashMapFunc(object.get()); 139 | return convertJNIObjectToJSIValue(runtime, hashMap); 140 | 141 | } 142 | 143 | auto type = object->getClass()->toString(); 144 | auto message = "Received unknown JNI type \"" + type + "\"! Cannot convert to jsi::Value."; 145 | __android_log_write(ANDROID_LOG_ERROR, "VisionCamera", message.c_str()); 146 | throw std::runtime_error(message); 147 | } 148 | 149 | } // namespace vision 150 | -------------------------------------------------------------------------------- /example/android/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # 4 | # Copyright 2015 the original author or authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | ## 21 | ## Gradle start up script for UN*X 22 | ## 23 | ############################################################################## 24 | 25 | # Attempt to set APP_HOME 26 | # Resolve links: $0 may be a link 27 | PRG="$0" 28 | # Need this for relative symlinks. 29 | while [ -h "$PRG" ] ; do 30 | ls=`ls -ld "$PRG"` 31 | link=`expr "$ls" : '.*-> \(.*\)$'` 32 | if expr "$link" : '/.*' > /dev/null; then 33 | PRG="$link" 34 | else 35 | PRG=`dirname "$PRG"`"/$link" 36 | fi 37 | done 38 | SAVED="`pwd`" 39 | cd "`dirname \"$PRG\"`/" >/dev/null 40 | APP_HOME="`pwd -P`" 41 | cd "$SAVED" >/dev/null 42 | 43 | APP_NAME="Gradle" 44 | APP_BASE_NAME=`basename "$0"` 45 | 46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 48 | 49 | # Use the maximum available, or set MAX_FD != -1 to use that value. 50 | MAX_FD="maximum" 51 | 52 | warn () { 53 | echo "$*" 54 | } 55 | 56 | die () { 57 | echo 58 | echo "$*" 59 | echo 60 | exit 1 61 | } 62 | 63 | # OS specific support (must be 'true' or 'false'). 64 | cygwin=false 65 | msys=false 66 | darwin=false 67 | nonstop=false 68 | case "`uname`" in 69 | CYGWIN* ) 70 | cygwin=true 71 | ;; 72 | Darwin* ) 73 | darwin=true 74 | ;; 75 | MINGW* ) 76 | msys=true 77 | ;; 78 | NONSTOP* ) 79 | nonstop=true 80 | ;; 81 | esac 82 | 83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 84 | 85 | # Determine the Java command to use to start the JVM. 86 | if [ -n "$JAVA_HOME" ] ; then 87 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 88 | # IBM's JDK on AIX uses strange locations for the executables 89 | JAVACMD="$JAVA_HOME/jre/sh/java" 90 | else 91 | JAVACMD="$JAVA_HOME/bin/java" 92 | fi 93 | if [ ! -x "$JAVACMD" ] ; then 94 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 95 | 96 | Please set the JAVA_HOME variable in your environment to match the 97 | location of your Java installation." 98 | fi 99 | else 100 | JAVACMD="java" 101 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 102 | 103 | Please set the JAVA_HOME variable in your environment to match the 104 | location of your Java installation." 105 | fi 106 | 107 | # Increase the maximum file descriptors if we can. 108 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 109 | MAX_FD_LIMIT=`ulimit -H -n` 110 | if [ $? -eq 0 ] ; then 111 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 112 | MAX_FD="$MAX_FD_LIMIT" 113 | fi 114 | ulimit -n $MAX_FD 115 | if [ $? -ne 0 ] ; then 116 | warn "Could not set maximum file descriptor limit: $MAX_FD" 117 | fi 118 | else 119 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 120 | fi 121 | fi 122 | 123 | # For Darwin, add options to specify how the application appears in the dock 124 | if $darwin; then 125 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 126 | fi 127 | 128 | # For Cygwin or MSYS, switch paths to Windows format before running java 129 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then 130 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 131 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 132 | JAVACMD=`cygpath --unix "$JAVACMD"` 133 | 134 | # We build the pattern for arguments to be converted via cygpath 135 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 136 | SEP="" 137 | for dir in $ROOTDIRSRAW ; do 138 | ROOTDIRS="$ROOTDIRS$SEP$dir" 139 | SEP="|" 140 | done 141 | OURCYGPATTERN="(^($ROOTDIRS))" 142 | # Add a user-defined pattern to the cygpath arguments 143 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 144 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 145 | fi 146 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 147 | i=0 148 | for arg in "$@" ; do 149 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 150 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 151 | 152 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 153 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 154 | else 155 | eval `echo args$i`="\"$arg\"" 156 | fi 157 | i=`expr $i + 1` 158 | done 159 | case $i in 160 | 0) set -- ;; 161 | 1) set -- "$args0" ;; 162 | 2) set -- "$args0" "$args1" ;; 163 | 3) set -- "$args0" "$args1" "$args2" ;; 164 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;; 165 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 166 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 167 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 168 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 169 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 170 | esac 171 | fi 172 | 173 | # Escape application args 174 | save () { 175 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 176 | echo " " 177 | } 178 | APP_ARGS=`save "$@"` 179 | 180 | # Collect all arguments for the java command, following the shell quoting and substitution rules 181 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 182 | 183 | exec "$JAVACMD" "$@" 184 | -------------------------------------------------------------------------------- /android/src/main/cpp/ContactHostObject.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Marc Rousavy on 30.09.21. 3 | // 4 | 5 | #include "ContactHostObject.h" 6 | 7 | #include 8 | #include 9 | #include "JSIJNIConversion.h" 10 | 11 | namespace mrousavy { 12 | 13 | using namespace facebook; 14 | 15 | ContactHostObject::~ContactHostObject() { 16 | // Hermes' Garbage Collector (Hades GC) calls destructors on a separate Thread 17 | // which might not be attached to JNI. Ensure that we use the JNI class loader when 18 | // deallocating the `frame` HybridClass, because otherwise JNI cannot call the Java 19 | // destroy() function. 20 | jni::ThreadScope::WithClassLoader([=] { _contact.reset(); }); 21 | } 22 | 23 | std::vector ContactHostObject::getPropertyNames(jsi::Runtime &rt) { 24 | std::vector result; 25 | result.push_back(jsi::PropNameID::forUtf8(rt, std::string("contactId"))); 26 | result.push_back(jsi::PropNameID::forUtf8(rt, std::string("displayName"))); 27 | result.push_back(jsi::PropNameID::forUtf8(rt, std::string("givenName"))); 28 | result.push_back(jsi::PropNameID::forUtf8(rt, std::string("middleName"))); 29 | result.push_back(jsi::PropNameID::forUtf8(rt, std::string("familyName"))); 30 | result.push_back(jsi::PropNameID::forUtf8(rt, std::string("prefix"))); 31 | result.push_back(jsi::PropNameID::forUtf8(rt, std::string("suffix"))); 32 | result.push_back(jsi::PropNameID::forUtf8(rt, std::string("company"))); 33 | result.push_back(jsi::PropNameID::forUtf8(rt, std::string("jobTitle"))); 34 | result.push_back(jsi::PropNameID::forUtf8(rt, std::string("department"))); 35 | result.push_back(jsi::PropNameID::forUtf8(rt, std::string("note"))); 36 | result.push_back(jsi::PropNameID::forUtf8(rt, std::string("urls"))); 37 | result.push_back(jsi::PropNameID::forUtf8(rt, std::string("instantMessengers"))); 38 | result.push_back(jsi::PropNameID::forUtf8(rt, std::string("hasPhoto"))); 39 | result.push_back(jsi::PropNameID::forUtf8(rt, std::string("photoUri"))); 40 | result.push_back(jsi::PropNameID::forUtf8(rt, std::string("emails"))); 41 | result.push_back(jsi::PropNameID::forUtf8(rt, std::string("phones"))); 42 | result.push_back(jsi::PropNameID::forUtf8(rt, std::string("postalAddresses"))); 43 | result.push_back(jsi::PropNameID::forUtf8(rt, std::string("birthday"))); 44 | return result; 45 | } 46 | 47 | jsi::Value ContactHostObject::get(jsi::Runtime& runtime, const jsi::PropNameID& propName) { 48 | auto name = propName.utf8(runtime); 49 | 50 | if (name == "contactId") { 51 | return vision::JSIJNIConversion::convertJNIObjectToJSIValue(runtime, 52 | _contact->getContactId()); 53 | } 54 | if (name == "displayName") { 55 | return vision::JSIJNIConversion::convertJNIObjectToJSIValue(runtime, 56 | _contact->getDisplayName()); 57 | } 58 | if (name == "givenName") { 59 | return vision::JSIJNIConversion::convertJNIObjectToJSIValue(runtime, 60 | _contact->getGivenName()); 61 | } 62 | if (name == "middleName") { 63 | return vision::JSIJNIConversion::convertJNIObjectToJSIValue(runtime, 64 | _contact->getMiddleName()); 65 | } 66 | if (name == "familyName") { 67 | return vision::JSIJNIConversion::convertJNIObjectToJSIValue(runtime, 68 | _contact->getFamilyName()); 69 | } 70 | if (name == "prefix") { 71 | return vision::JSIJNIConversion::convertJNIObjectToJSIValue(runtime, 72 | _contact->getPrefix()); 73 | } 74 | if (name == "suffix") { 75 | return vision::JSIJNIConversion::convertJNIObjectToJSIValue(runtime, 76 | _contact->getSuffix()); 77 | } 78 | if (name == "company") { 79 | return vision::JSIJNIConversion::convertJNIObjectToJSIValue(runtime, 80 | _contact->getCompany()); 81 | } 82 | if (name == "jobTitle") { 83 | return vision::JSIJNIConversion::convertJNIObjectToJSIValue(runtime, 84 | _contact->getJobTitle()); 85 | } 86 | if (name == "department") { 87 | return vision::JSIJNIConversion::convertJNIObjectToJSIValue(runtime, 88 | _contact->getDepartment()); 89 | } 90 | if (name == "note") { 91 | return vision::JSIJNIConversion::convertJNIObjectToJSIValue(runtime, 92 | _contact->getNote()); 93 | } 94 | if (name == "urls") { 95 | return vision::JSIJNIConversion::convertJNIObjectToJSIValue(runtime, 96 | _contact->getUrls()); 97 | } 98 | if (name == "instantMessengers") { 99 | return vision::JSIJNIConversion::convertJNIObjectToJSIValue(runtime, 100 | _contact->getInstantMessengers()); 101 | } 102 | if (name == "hasPhoto") { 103 | bool hasPhoto = _contact->getHasPhoto() == true; 104 | return jsi::Value(hasPhoto); 105 | } 106 | if (name == "photoUri") { 107 | return vision::JSIJNIConversion::convertJNIObjectToJSIValue(runtime, 108 | _contact->getPhotoUri()); 109 | } 110 | if (name == "emails") { 111 | return vision::JSIJNIConversion::convertJNIObjectToJSIValue(runtime, 112 | _contact->getEmails()); 113 | } 114 | if (name == "phones") { 115 | return vision::JSIJNIConversion::convertJNIObjectToJSIValue(runtime, 116 | _contact->getPhones()); 117 | } 118 | if (name == "postalAddresses") { 119 | return vision::JSIJNIConversion::convertJNIObjectToJSIValue(runtime, 120 | _contact->getPostalAddresses()); 121 | } 122 | if (name == "birthday") { 123 | return vision::JSIJNIConversion::convertJNIObjectToJSIValue(runtime, 124 | _contact->getBirthday()); 125 | } 126 | 127 | return jsi::Value::undefined(); 128 | } 129 | 130 | } 131 | -------------------------------------------------------------------------------- /android/src/main/cpp/JSIContacts.cpp: -------------------------------------------------------------------------------- 1 | #include "JSIContacts.h" 2 | #include 3 | #include 4 | #include 5 | #include "JSIJNIConversion.h" 6 | 7 | namespace mrousavy { 8 | 9 | jsi::Value JSIContacts::get(jsi::Runtime& runtime, const jsi::PropNameID& propName) { 10 | auto name = propName.utf8(runtime); 11 | 12 | if (name == "getContactsAsync") { 13 | return jsi::Function::createFromHostFunction(runtime, 14 | jsi::PropNameID::forAscii(runtime, "getContactsAsync"), 15 | 0, 16 | [this](jsi::Runtime& runtime, 17 | const jsi::Value&, 18 | const jsi::Value* arguments, 19 | size_t count) -> jsi::Value { 20 | return this->getContactsAsync(runtime); 21 | }); 22 | } 23 | if (name == "getHashAsync") { 24 | return jsi::Function::createFromHostFunction(runtime, 25 | jsi::PropNameID::forAscii(runtime, "getHashAsync"), 26 | 0, 27 | [this](jsi::Runtime& runtime, 28 | const jsi::Value&, 29 | const jsi::Value* arguments, 30 | size_t count) -> jsi::Value { 31 | return this->getHashAsync(runtime); 32 | }); 33 | } 34 | 35 | return jsi::Value::undefined(); 36 | } 37 | 38 | std::vector JSIContacts::getPropertyNames(jsi::Runtime &rt) { 39 | std::vector result; 40 | result.push_back(jsi::PropNameID::forUtf8(rt, std::string("getContactsAsync"))); 41 | result.push_back(jsi::PropNameID::forUtf8(rt, std::string("getHashAsync"))); 42 | return result; 43 | } 44 | 45 | jsi::Value JSIContacts::getContactsAsync(jsi::Runtime& runtime) { 46 | auto promiseCtor = runtime.global().getPropertyAsFunction(runtime, "Promise"); 47 | auto promiseCallback = [this](jsi::Runtime& runtime, 48 | const jsi::Value&, 49 | const jsi::Value* arguments, 50 | size_t count) -> jsi::Value { 51 | if (count != 2) { 52 | throw std::runtime_error("Promise Callback called with an unexpected amount of arguments!"); 53 | } 54 | auto resolver = std::make_shared(std::move(arguments[0].asObject(runtime).asFunction(runtime))); 55 | auto rejecter = std::make_shared(std::move(arguments[1].asObject(runtime).asFunction(runtime))); 56 | 57 | _threadPool.enqueue([this, &runtime, resolver, rejecter]() { 58 | try { 59 | jni::ThreadScope scope; 60 | auto contacts = this->_contactsProvider->getContacts(); 61 | // TODO: USE LOCAL REF DIRECTLY, THIS IS A WACK WORKAROUND! 62 | auto globalContacts = make_global(contacts); 63 | 64 | // ASYNC 65 | this->_callInvoker->invokeAsync([&runtime, resolver, globalContacts]() { 66 | jni::ThreadScope scope; 67 | // JS 68 | auto localAgain = make_local(globalContacts); 69 | auto jsiValue = vision::JSIJNIConversion::convertJNIObjectToJSIValue(runtime, localAgain); 70 | resolver->call(runtime, jsiValue); 71 | }); 72 | } catch (std::exception& exception) { 73 | auto message = std::string("Failed to get contacts! ") + std::string(exception.what()); 74 | this->_callInvoker->invokeAsync([&runtime, rejecter, message]() { 75 | auto error = jsi::JSError(runtime, message); 76 | rejecter->call(runtime, error.value()); 77 | }); 78 | } 79 | }); 80 | 81 | return jsi::Value::undefined(); 82 | }; 83 | auto promise = promiseCtor.callAsConstructor(runtime, 84 | jsi::Function::createFromHostFunction(runtime, 85 | jsi::PropNameID::forAscii(runtime, "PromiseCallback"), 86 | 2, 87 | std::move(promiseCallback))); 88 | return promise; 89 | } 90 | 91 | jsi::Value JSIContacts::getHashAsync(jsi::Runtime& runtime) { 92 | auto promiseCtor = runtime.global().getPropertyAsFunction(runtime, "Promise"); 93 | auto promiseCallback = [this](jsi::Runtime& runtime, 94 | const jsi::Value&, 95 | const jsi::Value* arguments, 96 | size_t count) -> jsi::Value { 97 | if (count != 2) { 98 | throw std::runtime_error("Promise Callback called with an unexpected amount of arguments!"); 99 | } 100 | auto resolver = std::make_shared(std::move(arguments[0].asObject(runtime).asFunction(runtime))); 101 | auto rejecter = std::make_shared(std::move(arguments[1].asObject(runtime).asFunction(runtime))); 102 | 103 | _threadPool.enqueue([this, &runtime, resolver, rejecter]() { 104 | try { 105 | jni::ThreadScope scope; 106 | auto hashJString = this->_contactsProvider->getHash(); 107 | std::string hash = hashJString->toStdString(); 108 | 109 | // ASYNC 110 | this->_callInvoker->invokeAsync([&runtime, resolver, hash]() { 111 | // JS 112 | auto jsiValue = jsi::String::createFromUtf8(runtime, hash); 113 | resolver->call(runtime, jsiValue); 114 | }); 115 | } catch (std::exception& exception) { 116 | auto message = std::string("Failed to get contacts hash! ") + std::string(exception.what()); 117 | this->_callInvoker->invokeAsync([&runtime, rejecter, message]() { 118 | auto error = jsi::JSError(runtime, message); 119 | rejecter->call(runtime, error.value()); 120 | }); 121 | } 122 | }); 123 | 124 | return jsi::Value::undefined(); 125 | }; 126 | auto promise = promiseCtor.callAsConstructor(runtime, 127 | jsi::Function::createFromHostFunction(runtime, 128 | jsi::PropNameID::forAscii(runtime, "PromiseCallback"), 129 | 2, 130 | std::move(promiseCallback))); 131 | return promise; 132 | } 133 | 134 | } 135 | -------------------------------------------------------------------------------- /example/android/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: "com.android.application" 2 | 3 | import com.android.build.OutputFile 4 | 5 | /** 6 | * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets 7 | * and bundleReleaseJsAndAssets). 8 | * These basically call `react-native bundle` with the correct arguments during the Android build 9 | * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the 10 | * bundle directly from the development server. Below you can see all the possible configurations 11 | * and their defaults. If you decide to add a configuration block, make sure to add it before the 12 | * `apply from: "../../node_modules/react-native/react.gradle"` line. 13 | * 14 | * project.ext.react = [ 15 | * // the name of the generated asset file containing your JS bundle 16 | * bundleAssetName: "index.android.bundle", 17 | * 18 | * // the entry file for bundle generation 19 | * entryFile: "index.android.js", 20 | * 21 | * // https://reactnative.dev/docs/performance#enable-the-ram-format 22 | * bundleCommand: "ram-bundle", 23 | * 24 | * // whether to bundle JS and assets in debug mode 25 | * bundleInDebug: false, 26 | * 27 | * // whether to bundle JS and assets in release mode 28 | * bundleInRelease: true, 29 | * 30 | * // whether to bundle JS and assets in another build variant (if configured). 31 | * // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants 32 | * // The configuration property can be in the following formats 33 | * // 'bundleIn${productFlavor}${buildType}' 34 | * // 'bundleIn${buildType}' 35 | * // bundleInFreeDebug: true, 36 | * // bundleInPaidRelease: true, 37 | * // bundleInBeta: true, 38 | * 39 | * // whether to disable dev mode in custom build variants (by default only disabled in release) 40 | * // for JsiContactsExample: to disable dev mode in the staging build type (if configured) 41 | * devDisabledInStaging: true, 42 | * // The configuration property can be in the following formats 43 | * // 'devDisabledIn${productFlavor}${buildType}' 44 | * // 'devDisabledIn${buildType}' 45 | * 46 | * // the root of your project, i.e. where "package.json" lives 47 | * root: "../../", 48 | * 49 | * // where to put the JS bundle asset in debug mode 50 | * jsBundleDirDebug: "$buildDir/intermediates/assets/debug", 51 | * 52 | * // where to put the JS bundle asset in release mode 53 | * jsBundleDirRelease: "$buildDir/intermediates/assets/release", 54 | * 55 | * // where to put drawable resources / React Native assets, e.g. the ones you use via 56 | * // require('./image.png')), in debug mode 57 | * resourcesDirDebug: "$buildDir/intermediates/res/merged/debug", 58 | * 59 | * // where to put drawable resources / React Native assets, e.g. the ones you use via 60 | * // require('./image.png')), in release mode 61 | * resourcesDirRelease: "$buildDir/intermediates/res/merged/release", 62 | * 63 | * // by default the gradle tasks are skipped if none of the JS files or assets change; this means 64 | * // that we don't look at files in android/ or ios/ to determine whether the tasks are up to 65 | * // date; if you have any other folders that you want to ignore for performance reasons (gradle 66 | * // indexes the entire tree), add them here. Alternatively, if you have JS files in android/ 67 | * // for JsiContactsExample, you might want to remove it from here. 68 | * inputExcludes: ["android/**", "ios/**"], 69 | * 70 | * // override which node gets called and with what additional arguments 71 | * nodeExecutableAndArgs: ["node"], 72 | * 73 | * // supply additional arguments to the packager 74 | * extraPackagerArgs: [] 75 | * ] 76 | */ 77 | 78 | project.ext.react = [ 79 | enableHermes: false, // clean and rebuild if changing 80 | entryFile: "index.tsx", 81 | ] 82 | 83 | apply from: "../../node_modules/react-native/react.gradle" 84 | 85 | /** 86 | * Set this to true to create two separate APKs instead of one: 87 | * - An APK that only works on ARM devices 88 | * - An APK that only works on x86 devices 89 | * The advantage is the size of the APK is reduced by about 4MB. 90 | * Upload all the APKs to the Play Store and people will download 91 | * the correct one based on the CPU architecture of their device. 92 | */ 93 | def enableSeparateBuildPerCPUArchitecture = false 94 | 95 | /** 96 | * Run Proguard to shrink the Java bytecode in release builds. 97 | */ 98 | def enableProguardInReleaseBuilds = false 99 | 100 | /** 101 | * The preferred build flavor of JavaScriptCore. 102 | * 103 | * For JsiContactsExample, to use the international variant, you can use: 104 | * `def jscFlavor = 'org.webkit:android-jsc-intl:+'` 105 | * 106 | * The international variant includes ICU i18n library and necessary data 107 | * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that 108 | * give correct results when using with locales other than en-US. Note that 109 | * this variant is about 6MiB larger per architecture than default. 110 | */ 111 | def jscFlavor = 'org.webkit:android-jsc:+' 112 | 113 | /** 114 | * Whether to enable the Hermes VM. 115 | * 116 | * This should be set on project.ext.react and mirrored here. If it is not set 117 | * on project.ext.react, JavaScript will not be compiled to Hermes Bytecode 118 | * and the benefits of using Hermes will therefore be sharply reduced. 119 | */ 120 | def enableHermes = project.ext.react.get("enableHermes", false); 121 | 122 | android { 123 | ndkVersion rootProject.ext.ndkVersion 124 | compileSdkVersion rootProject.ext.compileSdkVersion 125 | 126 | defaultConfig { 127 | applicationId "com.example.jsicontacts" 128 | minSdkVersion rootProject.ext.minSdkVersion 129 | targetSdkVersion rootProject.ext.targetSdkVersion 130 | versionCode 1 131 | versionName "1.0" 132 | } 133 | splits { 134 | abi { 135 | reset() 136 | enable enableSeparateBuildPerCPUArchitecture 137 | universalApk false // If true, also generate a universal APK 138 | include "armeabi-v7a", "x86", "arm64-v8a", "x86_64" 139 | } 140 | } 141 | signingConfigs { 142 | debug { 143 | storeFile file('debug.keystore') 144 | storePassword 'android' 145 | keyAlias 'androiddebugkey' 146 | keyPassword 'android' 147 | } 148 | } 149 | buildTypes { 150 | debug { 151 | signingConfig signingConfigs.debug 152 | } 153 | release { 154 | // Caution! In production, you need to generate your own keystore file. 155 | // see https://reactnative.dev/docs/signed-apk-android. 156 | signingConfig signingConfigs.debug 157 | minifyEnabled enableProguardInReleaseBuilds 158 | proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" 159 | } 160 | } 161 | // applicationVariants are e.g. debug, release 162 | applicationVariants.all { variant -> 163 | variant.outputs.each { output -> 164 | // For each separate APK per architecture, set a unique version code as described here: 165 | // https://developer.android.com/studio/build/configure-apk-splits.html 166 | def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4] 167 | def abi = output.getFilter(OutputFile.ABI) 168 | if (abi != null) { // null for the universal-debug, universal-release variants 169 | output.versionCodeOverride = 170 | defaultConfig.versionCode * 1000 + versionCodes.get(abi) 171 | } 172 | 173 | } 174 | } 175 | } 176 | 177 | dependencies { 178 | implementation fileTree(dir: "libs", include: ["*.jar"]) 179 | //noinspection GradleDynamicVersion 180 | implementation "com.facebook.react:react-native:+" // From node_modules 181 | 182 | 183 | implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0" 184 | debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") { 185 | exclude group:'com.facebook.fbjni' 186 | } 187 | debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") { 188 | exclude group:'com.facebook.flipper' 189 | exclude group:'com.squareup.okhttp3', module:'okhttp' 190 | } 191 | debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") { 192 | exclude group:'com.facebook.flipper' 193 | } 194 | 195 | if (enableHermes) { 196 | def hermesPath = "../../node_modules/hermes-engine/android/"; 197 | debugImplementation files(hermesPath + "hermes-debug.aar") 198 | releaseImplementation files(hermesPath + "hermes-release.aar") 199 | } else { 200 | implementation jscFlavor 201 | } 202 | implementation project(':jsicontacts') 203 | } 204 | 205 | // Run this once to be able to run the application with BUCK 206 | // puts all compile dependencies into folder libs for BUCK to use 207 | task copyDownloadableDepsToLibs(type: Copy) { 208 | from configurations.implementation 209 | into 'libs' 210 | } 211 | 212 | apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project) 213 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | We want this community to be friendly and respectful to each other. Please follow it in all your interactions with the project. 4 | 5 | ## Development workflow 6 | 7 | To get started with the project, run `yarn` in the root directory to install the required dependencies for each package: 8 | 9 | ```sh 10 | yarn 11 | ``` 12 | 13 | > While it's possible to use [`npm`](https://github.com/npm/cli), the tooling is built around [`yarn`](https://classic.yarnpkg.com/), so you'll have an easier time if you use `yarn` for development. 14 | 15 | While developing, you can run the [example app](/example/) to test your changes. Any changes you make in your library's JavaScript code will be reflected in the example app without a rebuild. If you change any native code, then you'll need to rebuild the example app. 16 | 17 | To start the packager: 18 | 19 | ```sh 20 | yarn example start 21 | ``` 22 | 23 | To run the example app on Android: 24 | 25 | ```sh 26 | yarn example android 27 | ``` 28 | 29 | To run the example app on iOS: 30 | 31 | ```sh 32 | yarn example ios 33 | ``` 34 | 35 | Make sure your code passes TypeScript and ESLint. Run the following to verify: 36 | 37 | ```sh 38 | yarn typescript 39 | yarn lint 40 | ``` 41 | 42 | To fix formatting errors, run the following: 43 | 44 | ```sh 45 | yarn lint --fix 46 | ``` 47 | 48 | Remember to add tests for your change if possible. Run the unit tests by: 49 | 50 | ```sh 51 | yarn test 52 | ``` 53 | 54 | To edit the Objective-C files, open `example/ios/JsiContactsExample.xcworkspace` in XCode and find the source files at `Pods > Development Pods > react-native-jsi-contacts`. 55 | 56 | To edit the Kotlin files, open `example/android` in Android studio and find the source files at `mrousavy.jsi.contacts` under `Android`. 57 | 58 | ### Commit message convention 59 | 60 | We follow the [conventional commits specification](https://www.conventionalcommits.org/en) for our commit messages: 61 | 62 | - `fix`: bug fixes, e.g. fix crash due to deprecated method. 63 | - `feat`: new features, e.g. add new method to the module. 64 | - `refactor`: code refactor, e.g. migrate from class components to hooks. 65 | - `docs`: changes into documentation, e.g. add usage example for the module.. 66 | - `test`: adding or updating tests, e.g. add integration tests using detox. 67 | - `chore`: tooling changes, e.g. change CI config. 68 | 69 | Our pre-commit hooks verify that your commit message matches this format when committing. 70 | 71 | ### Linting and tests 72 | 73 | [ESLint](https://eslint.org/), [Prettier](https://prettier.io/), [TypeScript](https://www.typescriptlang.org/) 74 | 75 | We use [TypeScript](https://www.typescriptlang.org/) for type checking, [ESLint](https://eslint.org/) with [Prettier](https://prettier.io/) for linting and formatting the code, and [Jest](https://jestjs.io/) for testing. 76 | 77 | Our pre-commit hooks verify that the linter and tests pass when committing. 78 | 79 | ### Publishing to npm 80 | 81 | We use [release-it](https://github.com/release-it/release-it) to make it easier to publish new versions. It handles common tasks like bumping version based on semver, creating tags and releases etc. 82 | 83 | To publish new versions, run the following: 84 | 85 | ```sh 86 | yarn release 87 | ``` 88 | 89 | ### Scripts 90 | 91 | The `package.json` file contains various scripts for common tasks: 92 | 93 | - `yarn bootstrap`: setup project by installing all dependencies and pods. 94 | - `yarn typescript`: type-check files with TypeScript. 95 | - `yarn lint`: lint files with ESLint. 96 | - `yarn test`: run unit tests with Jest. 97 | - `yarn example start`: start the Metro server for the example app. 98 | - `yarn example android`: run the example app on Android. 99 | - `yarn example ios`: run the example app on iOS. 100 | 101 | ### Sending a pull request 102 | 103 | > **Working on your first pull request?** You can learn how from this _free_ series: [How to Contribute to an Open Source Project on GitHub](https://app.egghead.io/playlists/how-to-contribute-to-an-open-source-project-on-github). 104 | 105 | When you're sending a pull request: 106 | 107 | - Prefer small pull requests focused on one change. 108 | - Verify that linters and tests are passing. 109 | - Review the documentation to make sure it looks good. 110 | - Follow the pull request template when opening a pull request. 111 | - For pull requests that change the API or implementation, discuss with maintainers first by opening an issue. 112 | 113 | ## Code of Conduct 114 | 115 | ### Our Pledge 116 | 117 | We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation. 118 | 119 | We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community. 120 | 121 | ### Our Standards 122 | 123 | Examples of behavior that contributes to a positive environment for our community include: 124 | 125 | - Demonstrating empathy and kindness toward other people 126 | - Being respectful of differing opinions, viewpoints, and experiences 127 | - Giving and gracefully accepting constructive feedback 128 | - Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience 129 | - Focusing on what is best not just for us as individuals, but for the overall community 130 | 131 | Examples of unacceptable behavior include: 132 | 133 | - The use of sexualized language or imagery, and sexual attention or 134 | advances of any kind 135 | - Trolling, insulting or derogatory comments, and personal or political attacks 136 | - Public or private harassment 137 | - Publishing others' private information, such as a physical or email 138 | address, without their explicit permission 139 | - Other conduct which could reasonably be considered inappropriate in a 140 | professional setting 141 | 142 | ### Enforcement Responsibilities 143 | 144 | Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful. 145 | 146 | Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate. 147 | 148 | ### Scope 149 | 150 | This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. 151 | 152 | ### Enforcement 153 | 154 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at [INSERT CONTACT METHOD]. All complaints will be reviewed and investigated promptly and fairly. 155 | 156 | All community leaders are obligated to respect the privacy and security of the reporter of any incident. 157 | 158 | ### Enforcement Guidelines 159 | 160 | Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct: 161 | 162 | #### 1. Correction 163 | 164 | **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community. 165 | 166 | **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested. 167 | 168 | #### 2. Warning 169 | 170 | **Community Impact**: A violation through a single incident or series of actions. 171 | 172 | **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban. 173 | 174 | #### 3. Temporary Ban 175 | 176 | **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior. 177 | 178 | **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban. 179 | 180 | #### 4. Permanent Ban 181 | 182 | **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals. 183 | 184 | **Consequence**: A permanent ban from any sort of public interaction within the community. 185 | 186 | ### Attribution 187 | 188 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0, 189 | available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. 190 | 191 | Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity). 192 | 193 | [homepage]: https://www.contributor-covenant.org 194 | 195 | For answers to common questions about this code of conduct, see the FAQ at 196 | https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations. 197 | -------------------------------------------------------------------------------- /ios/JsiContacts.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 11 | 5E46D8CD2428F78900513E24 /* example.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5E46D8CB2428F78900513E24 /* example.cpp */; }; 12 | 5E555C0D2413F4C50049A1A2 /* JsiContacts.mm in Sources */ = {isa = PBXBuildFile; fileRef = B3E7B5891CC2AC0600A0062D /* JsiContacts.mm */; }; 13 | 14 | /* End PBXBuildFile section */ 15 | 16 | /* Begin PBXCopyFilesBuildPhase section */ 17 | 58B511D91A9E6C8500147676 /* CopyFiles */ = { 18 | isa = PBXCopyFilesBuildPhase; 19 | buildActionMask = 2147483647; 20 | dstPath = "include/$(PRODUCT_NAME)"; 21 | dstSubfolderSpec = 16; 22 | files = ( 23 | ); 24 | runOnlyForDeploymentPostprocessing = 0; 25 | }; 26 | /* End PBXCopyFilesBuildPhase section */ 27 | 28 | /* Begin PBXFileReference section */ 29 | 134814201AA4EA6300B7C361 /* libJsiContacts.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libJsiContacts.a; sourceTree = BUILT_PRODUCTS_DIR; }; 30 | 31 | 5E46D8CB2428F78900513E24 /* example.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = example.cpp; path = ../cpp/example.cpp; sourceTree = ""; }; 32 | 5E46D8CC2428F78900513E24 /* example.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = example.h; path = ../cpp/example.h; sourceTree = ""; }; 33 | B3E7B5891CC2AC0600A0062D /* JsiContacts.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = JsiContacts.mm; sourceTree = ""; }; 34 | 35 | /* End PBXFileReference section */ 36 | 37 | /* Begin PBXFrameworksBuildPhase section */ 38 | 58B511D81A9E6C8500147676 /* Frameworks */ = { 39 | isa = PBXFrameworksBuildPhase; 40 | buildActionMask = 2147483647; 41 | files = ( 42 | ); 43 | runOnlyForDeploymentPostprocessing = 0; 44 | }; 45 | /* End PBXFrameworksBuildPhase section */ 46 | 47 | /* Begin PBXGroup section */ 48 | 134814211AA4EA7D00B7C361 /* Products */ = { 49 | isa = PBXGroup; 50 | children = ( 51 | 134814201AA4EA6300B7C361 /* libJsiContacts.a */, 52 | ); 53 | name = Products; 54 | sourceTree = ""; 55 | }; 56 | 58B511D21A9E6C8500147676 = { 57 | isa = PBXGroup; 58 | children = ( 59 | 60 | 5E46D8CB2428F78900513E24 /* example.cpp */, 61 | 5E46D8CC2428F78900513E24 /* example.h */, 62 | B3E7B5891CC2AC0600A0062D /* JsiContacts.mm */, 63 | 64 | 134814211AA4EA7D00B7C361 /* Products */, 65 | ); 66 | sourceTree = ""; 67 | }; 68 | /* End PBXGroup section */ 69 | 70 | /* Begin PBXNativeTarget section */ 71 | 58B511DA1A9E6C8500147676 /* JsiContacts */ = { 72 | isa = PBXNativeTarget; 73 | buildConfigurationList = 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "JsiContacts" */; 74 | buildPhases = ( 75 | 58B511D71A9E6C8500147676 /* Sources */, 76 | 58B511D81A9E6C8500147676 /* Frameworks */, 77 | 58B511D91A9E6C8500147676 /* CopyFiles */, 78 | ); 79 | buildRules = ( 80 | ); 81 | dependencies = ( 82 | ); 83 | name = JsiContacts; 84 | productName = RCTDataManager; 85 | productReference = 134814201AA4EA6300B7C361 /* libJsiContacts.a */; 86 | productType = "com.apple.product-type.library.static"; 87 | }; 88 | /* End PBXNativeTarget section */ 89 | 90 | /* Begin PBXProject section */ 91 | 58B511D31A9E6C8500147676 /* Project object */ = { 92 | isa = PBXProject; 93 | attributes = { 94 | LastUpgradeCheck = 0920; 95 | ORGANIZATIONNAME = Facebook; 96 | TargetAttributes = { 97 | 58B511DA1A9E6C8500147676 = { 98 | CreatedOnToolsVersion = 6.1.1; 99 | }; 100 | }; 101 | }; 102 | buildConfigurationList = 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "JsiContacts" */; 103 | compatibilityVersion = "Xcode 3.2"; 104 | developmentRegion = English; 105 | hasScannedForEncodings = 0; 106 | knownRegions = ( 107 | English, 108 | en, 109 | ); 110 | mainGroup = 58B511D21A9E6C8500147676; 111 | productRefGroup = 58B511D21A9E6C8500147676; 112 | projectDirPath = ""; 113 | projectRoot = ""; 114 | targets = ( 115 | 58B511DA1A9E6C8500147676 /* JsiContacts */, 116 | ); 117 | }; 118 | /* End PBXProject section */ 119 | 120 | /* Begin PBXSourcesBuildPhase section */ 121 | 58B511D71A9E6C8500147676 /* Sources */ = { 122 | isa = PBXSourcesBuildPhase; 123 | buildActionMask = 2147483647; 124 | files = ( 125 | 126 | 5E46D8CD2428F78900513E24 /* example.cpp in Sources */, 127 | 5E555C0D2413F4C50049A1A2 /* JsiContacts.mm in Sources */, 128 | 129 | ); 130 | runOnlyForDeploymentPostprocessing = 0; 131 | }; 132 | /* End PBXSourcesBuildPhase section */ 133 | 134 | /* Begin XCBuildConfiguration section */ 135 | 58B511ED1A9E6C8500147676 /* Debug */ = { 136 | isa = XCBuildConfiguration; 137 | buildSettings = { 138 | ALWAYS_SEARCH_USER_PATHS = NO; 139 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 140 | CLANG_CXX_LIBRARY = "libc++"; 141 | CLANG_ENABLE_MODULES = YES; 142 | CLANG_ENABLE_OBJC_ARC = YES; 143 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 144 | CLANG_WARN_BOOL_CONVERSION = YES; 145 | CLANG_WARN_COMMA = YES; 146 | CLANG_WARN_CONSTANT_CONVERSION = YES; 147 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 148 | CLANG_WARN_EMPTY_BODY = YES; 149 | CLANG_WARN_ENUM_CONVERSION = YES; 150 | CLANG_WARN_INFINITE_RECURSION = YES; 151 | CLANG_WARN_INT_CONVERSION = YES; 152 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 153 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 154 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 155 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 156 | CLANG_WARN_STRICT_PROTOTYPES = YES; 157 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 158 | CLANG_WARN_UNREACHABLE_CODE = YES; 159 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 160 | COPY_PHASE_STRIP = NO; 161 | ENABLE_STRICT_OBJC_MSGSEND = YES; 162 | ENABLE_TESTABILITY = YES; 163 | GCC_C_LANGUAGE_STANDARD = gnu99; 164 | GCC_DYNAMIC_NO_PIC = NO; 165 | GCC_NO_COMMON_BLOCKS = YES; 166 | GCC_OPTIMIZATION_LEVEL = 0; 167 | GCC_PREPROCESSOR_DEFINITIONS = ( 168 | "DEBUG=1", 169 | "$(inherited)", 170 | ); 171 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 172 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 173 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 174 | GCC_WARN_UNDECLARED_SELECTOR = YES; 175 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 176 | GCC_WARN_UNUSED_FUNCTION = YES; 177 | GCC_WARN_UNUSED_VARIABLE = YES; 178 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 179 | MTL_ENABLE_DEBUG_INFO = YES; 180 | ONLY_ACTIVE_ARCH = YES; 181 | SDKROOT = iphoneos; 182 | }; 183 | name = Debug; 184 | }; 185 | 58B511EE1A9E6C8500147676 /* Release */ = { 186 | isa = XCBuildConfiguration; 187 | buildSettings = { 188 | ALWAYS_SEARCH_USER_PATHS = NO; 189 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 190 | CLANG_CXX_LIBRARY = "libc++"; 191 | CLANG_ENABLE_MODULES = YES; 192 | CLANG_ENABLE_OBJC_ARC = YES; 193 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 194 | CLANG_WARN_BOOL_CONVERSION = YES; 195 | CLANG_WARN_COMMA = YES; 196 | CLANG_WARN_CONSTANT_CONVERSION = YES; 197 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 198 | CLANG_WARN_EMPTY_BODY = YES; 199 | CLANG_WARN_ENUM_CONVERSION = YES; 200 | CLANG_WARN_INFINITE_RECURSION = YES; 201 | CLANG_WARN_INT_CONVERSION = YES; 202 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 203 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 204 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 205 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 206 | CLANG_WARN_STRICT_PROTOTYPES = YES; 207 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 208 | CLANG_WARN_UNREACHABLE_CODE = YES; 209 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 210 | COPY_PHASE_STRIP = YES; 211 | ENABLE_NS_ASSERTIONS = NO; 212 | ENABLE_STRICT_OBJC_MSGSEND = YES; 213 | GCC_C_LANGUAGE_STANDARD = gnu99; 214 | GCC_NO_COMMON_BLOCKS = YES; 215 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 216 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 217 | GCC_WARN_UNDECLARED_SELECTOR = YES; 218 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 219 | GCC_WARN_UNUSED_FUNCTION = YES; 220 | GCC_WARN_UNUSED_VARIABLE = YES; 221 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 222 | MTL_ENABLE_DEBUG_INFO = NO; 223 | SDKROOT = iphoneos; 224 | VALIDATE_PRODUCT = YES; 225 | }; 226 | name = Release; 227 | }; 228 | 58B511F01A9E6C8500147676 /* Debug */ = { 229 | isa = XCBuildConfiguration; 230 | buildSettings = { 231 | HEADER_SEARCH_PATHS = ( 232 | "$(inherited)", 233 | /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, 234 | "$(SRCROOT)/../../../React/**", 235 | "$(SRCROOT)/../../react-native/React/**", 236 | ); 237 | LIBRARY_SEARCH_PATHS = "$(inherited)"; 238 | OTHER_LDFLAGS = "-ObjC"; 239 | PRODUCT_NAME = JsiContacts; 240 | SKIP_INSTALL = YES; 241 | 242 | }; 243 | name = Debug; 244 | }; 245 | 58B511F11A9E6C8500147676 /* Release */ = { 246 | isa = XCBuildConfiguration; 247 | buildSettings = { 248 | HEADER_SEARCH_PATHS = ( 249 | "$(inherited)", 250 | /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, 251 | "$(SRCROOT)/../../../React/**", 252 | "$(SRCROOT)/../../react-native/React/**", 253 | ); 254 | LIBRARY_SEARCH_PATHS = "$(inherited)"; 255 | OTHER_LDFLAGS = "-ObjC"; 256 | PRODUCT_NAME = JsiContacts; 257 | SKIP_INSTALL = YES; 258 | 259 | }; 260 | name = Release; 261 | }; 262 | /* End XCBuildConfiguration section */ 263 | 264 | /* Begin XCConfigurationList section */ 265 | 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "JsiContacts" */ = { 266 | isa = XCConfigurationList; 267 | buildConfigurations = ( 268 | 58B511ED1A9E6C8500147676 /* Debug */, 269 | 58B511EE1A9E6C8500147676 /* Release */, 270 | ); 271 | defaultConfigurationIsVisible = 0; 272 | defaultConfigurationName = Release; 273 | }; 274 | 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "JsiContacts" */ = { 275 | isa = XCConfigurationList; 276 | buildConfigurations = ( 277 | 58B511F01A9E6C8500147676 /* Debug */, 278 | 58B511F11A9E6C8500147676 /* Release */, 279 | ); 280 | defaultConfigurationIsVisible = 0; 281 | defaultConfigurationName = Release; 282 | }; 283 | /* End XCConfigurationList section */ 284 | }; 285 | rootObject = 58B511D31A9E6C8500147676 /* Project object */; 286 | } 287 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | import groovy.json.JsonSlurper 2 | import org.apache.tools.ant.filters.ReplaceTokens 3 | import java.nio.file.Paths 4 | 5 | buildscript { 6 | repositories { 7 | google() 8 | jcenter() 9 | maven { 10 | url "https://plugins.gradle.org/m2/" 11 | } 12 | } 13 | 14 | dependencies { 15 | classpath 'com.android.tools.build:gradle:4.2.2' 16 | classpath 'de.undercouch:gradle-download-task:4.1.2' 17 | } 18 | } 19 | 20 | apply plugin: 'com.android.library' 21 | apply plugin: 'de.undercouch.download' 22 | 23 | def getExtOrDefault(name) { 24 | return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['JsiContacts_' + name] 25 | } 26 | 27 | def getExtOrIntegerDefault(name) { 28 | return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties['JsiContacts_' + name]).toInteger() 29 | } 30 | 31 | android { 32 | compileSdkVersion getExtOrIntegerDefault('compileSdkVersion') 33 | buildToolsVersion getExtOrDefault('buildToolsVersion') 34 | ndkVersion getExtOrDefault('ndkVersion') 35 | 36 | defaultConfig { 37 | minSdkVersion 21 38 | targetSdkVersion getExtOrIntegerDefault('targetSdkVersion') 39 | versionCode 1 40 | versionName "1.0" 41 | externalNativeBuild { 42 | cmake { 43 | cppFlags "-fexceptions", "-frtti", "-std=c++1y", "-DONANDROID" 44 | abiFilters 'x86', 'x86_64', 'armeabi-v7a', 'arm64-v8a' 45 | arguments '-DANDROID_STL=c++_shared', 46 | "-DNODE_MODULES_DIR=${rootDir}/../node_modules" 47 | } 48 | } 49 | } 50 | 51 | dexOptions { 52 | javaMaxHeapSize "4g" 53 | } 54 | 55 | externalNativeBuild { 56 | cmake { 57 | path "CMakeLists.txt" 58 | } 59 | } 60 | 61 | packagingOptions { 62 | excludes = ["**/libc++_shared.so", "**/libfbjni.so"] 63 | } 64 | 65 | buildTypes { 66 | release { 67 | minifyEnabled false 68 | } 69 | } 70 | lintOptions { 71 | disable 'GradleCompatible' 72 | } 73 | compileOptions { 74 | sourceCompatibility JavaVersion.VERSION_1_8 75 | targetCompatibility JavaVersion.VERSION_1_8 76 | } 77 | 78 | configurations { 79 | extractHeaders 80 | extractJNI 81 | } 82 | } 83 | 84 | repositories { 85 | mavenCentral() 86 | google() 87 | 88 | def found = false 89 | def defaultDir = null 90 | def androidSourcesName = 'React Native sources' 91 | 92 | if (rootProject.ext.has('reactNativeAndroidRoot')) { 93 | defaultDir = rootProject.ext.get('reactNativeAndroidRoot') 94 | } else { 95 | defaultDir = new File( 96 | projectDir, 97 | '/../../../node_modules/react-native/android' 98 | ) 99 | } 100 | 101 | if (defaultDir.exists()) { 102 | maven { 103 | url defaultDir.toString() 104 | name androidSourcesName 105 | } 106 | 107 | logger.info(":${project.name}:reactNativeAndroidRoot ${defaultDir.canonicalPath}") 108 | found = true 109 | } else { 110 | def parentDir = rootProject.projectDir 111 | 112 | 1.upto(5, { 113 | if (found) return true 114 | parentDir = parentDir.parentFile 115 | 116 | def androidSourcesDir = new File( 117 | parentDir, 118 | 'node_modules/react-native' 119 | ) 120 | 121 | def androidPrebuiltBinaryDir = new File( 122 | parentDir, 123 | 'node_modules/react-native/android' 124 | ) 125 | 126 | if (androidPrebuiltBinaryDir.exists()) { 127 | maven { 128 | url androidPrebuiltBinaryDir.toString() 129 | name androidSourcesName 130 | } 131 | 132 | logger.info(":${project.name}:reactNativeAndroidRoot ${androidPrebuiltBinaryDir.canonicalPath}") 133 | found = true 134 | } else if (androidSourcesDir.exists()) { 135 | maven { 136 | url androidSourcesDir.toString() 137 | name androidSourcesName 138 | } 139 | 140 | logger.info(":${project.name}:reactNativeAndroidRoot ${androidSourcesDir.canonicalPath}") 141 | found = true 142 | } 143 | }) 144 | } 145 | 146 | if (!found) { 147 | throw new GradleException( 148 | "${project.name}: unable to locate React Native android sources. " + 149 | "Ensure you have you installed React Native as a dependency in your project and try again." 150 | ) 151 | } 152 | } 153 | 154 | dependencies { 155 | // noinspection GradleDynamicVersion 156 | implementation 'com.facebook.react:react-native:+' 157 | 158 | //noinspection GradleDynamicVersion 159 | extractHeaders("com.facebook.fbjni:fbjni:+:headers") 160 | //noinspection GradleDynamicVersion 161 | extractJNI("com.facebook.fbjni:fbjni:+") 162 | 163 | def rnAAR = fileTree("${rootDir}/../node_modules/react-native/android").matching({ it.include "**/**/*.aar" }).singleFile 164 | extractJNI(files(rnAAR)) 165 | } 166 | 167 | 168 | // third-party-ndk deps headers 169 | // mostly a copy of https://github.com/software-mansion/react-native-reanimated/blob/master/android/build.gradle#L115 170 | 171 | def downloadsDir = new File("$buildDir/downloads") 172 | def thirdPartyNdkDir = new File("$buildDir/third-party-ndk") 173 | def thirdPartyVersionsFile = new File("${rootDir}/../node_modules/react-native/ReactAndroid/gradle.properties") 174 | def thirdPartyVersions = new Properties() 175 | thirdPartyVersions.load(new FileInputStream(thirdPartyVersionsFile)) 176 | 177 | def BOOST_VERSION = thirdPartyVersions["BOOST_VERSION"] 178 | def boost_file = new File(downloadsDir, "boost_${BOOST_VERSION}.tar.gz") 179 | def DOUBLE_CONVERSION_VERSION = thirdPartyVersions["DOUBLE_CONVERSION_VERSION"] 180 | def double_conversion_file = new File(downloadsDir, "double-conversion-${DOUBLE_CONVERSION_VERSION}.tar.gz") 181 | def FOLLY_VERSION = thirdPartyVersions["FOLLY_VERSION"] 182 | def folly_file = new File(downloadsDir, "folly-${FOLLY_VERSION}.tar.gz") 183 | def GLOG_VERSION = thirdPartyVersions["GLOG_VERSION"] 184 | def glog_file = new File(downloadsDir, "glog-${GLOG_VERSION}.tar.gz") 185 | 186 | task createNativeDepsDirectories { 187 | doLast { 188 | downloadsDir.mkdirs() 189 | thirdPartyNdkDir.mkdirs() 190 | } 191 | } 192 | 193 | task downloadBoost(dependsOn: createNativeDepsDirectories, type: Download) { 194 | src("https://github.com/react-native-community/boost-for-react-native/releases/download/v${BOOST_VERSION.replace("_", ".")}-0/boost_${BOOST_VERSION}.tar.gz") 195 | onlyIfNewer(true) 196 | overwrite(false) 197 | dest(boost_file) 198 | } 199 | 200 | task prepareBoost(dependsOn: downloadBoost, type: Copy) { 201 | from(tarTree(resources.gzip(downloadBoost.dest))) 202 | from("src/main/jni/third-party/boost/Android.mk") 203 | include("Android.mk", "boost_${BOOST_VERSION}/boost/**/*.hpp", "boost/boost/**/*.hpp") 204 | includeEmptyDirs = false 205 | into("$thirdPartyNdkDir") // /boost_X_XX_X 206 | doLast { 207 | file("$thirdPartyNdkDir/boost_${BOOST_VERSION}").renameTo("$thirdPartyNdkDir/boost") 208 | } 209 | } 210 | 211 | task downloadDoubleConversion(dependsOn: createNativeDepsDirectories, type: Download) { 212 | src("https://github.com/google/double-conversion/archive/v${DOUBLE_CONVERSION_VERSION}.tar.gz") 213 | onlyIfNewer(true) 214 | overwrite(false) 215 | dest(double_conversion_file) 216 | } 217 | 218 | task prepareDoubleConversion(dependsOn: downloadDoubleConversion, type: Copy) { 219 | from(tarTree(downloadDoubleConversion.dest)) 220 | from("src/main/jni/third-party/double-conversion/Android.mk") 221 | include("double-conversion-${DOUBLE_CONVERSION_VERSION}/src/**/*", "Android.mk") 222 | filesMatching("*/src/**/*", { fname -> fname.path = "double-conversion/${fname.name}" }) 223 | includeEmptyDirs = false 224 | into("$thirdPartyNdkDir/double-conversion") 225 | } 226 | 227 | task downloadFolly(dependsOn: createNativeDepsDirectories, type: Download) { 228 | src("https://github.com/facebook/folly/archive/v${FOLLY_VERSION}.tar.gz") 229 | onlyIfNewer(true) 230 | overwrite(false) 231 | dest(folly_file) 232 | } 233 | 234 | task prepareFolly(dependsOn: downloadFolly, type: Copy) { 235 | from(tarTree(downloadFolly.dest)) 236 | from("src/main/jni/third-party/folly/Android.mk") 237 | include("folly-${FOLLY_VERSION}/folly/**/*", "Android.mk") 238 | eachFile { fname -> fname.path = (fname.path - "folly-${FOLLY_VERSION}/") } 239 | includeEmptyDirs = false 240 | into("$thirdPartyNdkDir/folly") 241 | } 242 | 243 | task downloadGlog(dependsOn: createNativeDepsDirectories, type: Download) { 244 | src("https://github.com/google/glog/archive/v${GLOG_VERSION}.tar.gz") 245 | onlyIfNewer(true) 246 | overwrite(false) 247 | dest(glog_file) 248 | } 249 | 250 | task prepareGlog(dependsOn: downloadGlog, type: Copy) { 251 | from(tarTree(downloadGlog.dest)) 252 | from("src/main/jni/third-party/glog/") 253 | include("glog-${GLOG_VERSION}/src/**/*", "Android.mk", "config.h") 254 | includeEmptyDirs = false 255 | filesMatching("**/*.h.in") { 256 | filter(ReplaceTokens, tokens: [ 257 | ac_cv_have_unistd_h : "1", 258 | ac_cv_have_stdint_h : "1", 259 | ac_cv_have_systypes_h : "1", 260 | ac_cv_have_inttypes_h : "1", 261 | ac_cv_have_libgflags : "0", 262 | ac_google_start_namespace : "namespace google {", 263 | ac_cv_have_uint16_t : "1", 264 | ac_cv_have_u_int16_t : "1", 265 | ac_cv_have___uint16 : "0", 266 | ac_google_end_namespace : "}", 267 | ac_cv_have___builtin_expect : "1", 268 | ac_google_namespace : "google", 269 | ac_cv___attribute___noinline : "__attribute__ ((noinline))", 270 | ac_cv___attribute___noreturn : "__attribute__ ((noreturn))", 271 | ac_cv___attribute___printf_4_5: "__attribute__((__format__ (__printf__, 4, 5)))" 272 | ]) 273 | it.path = (it.name - ".in") 274 | } 275 | into("$thirdPartyNdkDir/glog") 276 | 277 | doLast { 278 | copy { 279 | from(fileTree(dir: "$thirdPartyNdkDir/glog", includes: ["stl_logging.h", "logging.h", "raw_logging.h", "vlog_is_on.h", "**/src/glog/log_severity.h"]).files) 280 | includeEmptyDirs = false 281 | into("$thirdPartyNdkDir/glog/exported/glog") 282 | } 283 | } 284 | } 285 | 286 | task prepareThirdPartyNdkHeaders { 287 | if (!boost_file.exists()) { 288 | dependsOn(prepareBoost) 289 | } 290 | if (!double_conversion_file.exists()) { 291 | dependsOn(prepareDoubleConversion) 292 | } 293 | if (!folly_file.exists()) { 294 | dependsOn(prepareFolly) 295 | } 296 | if (!glog_file.exists()) { 297 | dependsOn(prepareGlog) 298 | } 299 | } 300 | 301 | prepareThirdPartyNdkHeaders.mustRunAfter createNativeDepsDirectories 302 | 303 | task extractAARHeaders { 304 | doLast { 305 | configurations.extractHeaders.files.each { 306 | def file = it.absoluteFile 307 | copy { 308 | from zipTree(file) 309 | into "$buildDir/$file.name" 310 | include "**/*.h" 311 | } 312 | } 313 | } 314 | } 315 | extractAARHeaders.mustRunAfter prepareThirdPartyNdkHeaders 316 | 317 | task extractJNIFiles { 318 | doLast { 319 | configurations.extractJNI.files.each { 320 | def file = it.absoluteFile 321 | 322 | copy { 323 | from zipTree(file) 324 | into "$buildDir/$file.name" 325 | include "jni/**/*" 326 | } 327 | } 328 | } 329 | } 330 | extractJNIFiles.mustRunAfter extractAARHeaders 331 | 332 | tasks.whenTaskAdded { task -> 333 | if (task.name == 'externalNativeBuildDebug' || task.name == 'externalNativeBuildRelease') { 334 | task.dependsOn(extractAARHeaders) 335 | task.dependsOn(extractJNIFiles) 336 | task.dependsOn(prepareThirdPartyNdkHeaders) 337 | } 338 | } 339 | -------------------------------------------------------------------------------- /android/src/main/java/com/mrousavy/jsi/contacts/ContactsProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Original source code copied from https://github.com/morenoh149/react-native-contacts/blob/master/android/src/main/java/com/rt2zz/reactnativecontacts/ContactsProvider.java 3 | * All credits belongs to the original source. 4 | */ 5 | 6 | package com.mrousavy.jsi.contacts; 7 | 8 | import android.content.ContentResolver; 9 | import android.database.Cursor; 10 | import android.net.Uri; 11 | import android.provider.ContactsContract; 12 | import androidx.annotation.NonNull; 13 | import android.text.TextUtils; 14 | import android.util.Log; 15 | 16 | import java.security.MessageDigest; 17 | import java.security.NoSuchAlgorithmException; 18 | import java.util.ArrayList; 19 | import java.util.Arrays; 20 | import java.util.LinkedHashMap; 21 | import java.util.List; 22 | import java.util.Map; 23 | 24 | import static android.provider.ContactsContract.CommonDataKinds.Contactables; 25 | import static android.provider.ContactsContract.CommonDataKinds.Email; 26 | import static android.provider.ContactsContract.CommonDataKinds.Event; 27 | import static android.provider.ContactsContract.CommonDataKinds.Organization; 28 | import static android.provider.ContactsContract.CommonDataKinds.Phone; 29 | import static android.provider.ContactsContract.CommonDataKinds.StructuredName; 30 | import static android.provider.ContactsContract.CommonDataKinds.Note; 31 | import static android.provider.ContactsContract.CommonDataKinds.Website; 32 | import static android.provider.ContactsContract.CommonDataKinds.Im; 33 | import static android.provider.ContactsContract.CommonDataKinds.StructuredPostal; 34 | 35 | import com.facebook.proguard.annotations.DoNotStrip; 36 | 37 | @DoNotStrip 38 | public class ContactsProvider { 39 | public static final int ID_FOR_PROFILE_CONTACT = -1; 40 | 41 | private static final List JUST_ME_PROJECTION = new ArrayList() {{ 42 | add((ContactsContract.Data._ID)); 43 | add(ContactsContract.Data.CONTACT_ID); 44 | add(ContactsContract.Data.RAW_CONTACT_ID); 45 | add(ContactsContract.Data.LOOKUP_KEY); 46 | add(ContactsContract.Contacts.Data.MIMETYPE); 47 | add(ContactsContract.Profile.DISPLAY_NAME); 48 | add(Contactables.PHOTO_URI); 49 | add(StructuredName.DISPLAY_NAME); 50 | add(StructuredName.GIVEN_NAME); 51 | add(StructuredName.MIDDLE_NAME); 52 | add(StructuredName.FAMILY_NAME); 53 | add(StructuredName.PREFIX); 54 | add(StructuredName.SUFFIX); 55 | add(Phone.NUMBER); 56 | add(Phone.NORMALIZED_NUMBER); 57 | add(Phone.TYPE); 58 | add(Phone.LABEL); 59 | add(Email.DATA); 60 | add(Email.ADDRESS); 61 | add(Email.TYPE); 62 | add(Email.LABEL); 63 | add(Organization.COMPANY); 64 | add(Organization.TITLE); 65 | add(Organization.DEPARTMENT); 66 | add(StructuredPostal.FORMATTED_ADDRESS); 67 | add(StructuredPostal.TYPE); 68 | add(StructuredPostal.LABEL); 69 | add(StructuredPostal.STREET); 70 | add(StructuredPostal.POBOX); 71 | add(StructuredPostal.NEIGHBORHOOD); 72 | add(StructuredPostal.CITY); 73 | add(StructuredPostal.REGION); 74 | add(StructuredPostal.POSTCODE); 75 | add(StructuredPostal.COUNTRY); 76 | add(Note.NOTE); 77 | add(Website.URL); 78 | add(Im.DATA); 79 | add(Event.START_DATE); 80 | add(Event.TYPE); 81 | }}; 82 | 83 | private static final List FULL_PROJECTION = new ArrayList() {{ 84 | addAll(JUST_ME_PROJECTION); 85 | }}; 86 | 87 | private final ContentResolver contentResolver; 88 | 89 | public ContactsProvider(ContentResolver contentResolver) { 90 | this.contentResolver = contentResolver; 91 | } 92 | 93 | @DoNotStrip 94 | public Map getContacts() { 95 | Map justMe; 96 | { 97 | try (Cursor cursor = contentResolver.query( 98 | Uri.withAppendedPath(ContactsContract.Profile.CONTENT_URI, ContactsContract.Contacts.Data.CONTENT_DIRECTORY), 99 | JUST_ME_PROJECTION.toArray(new String[JUST_ME_PROJECTION.size()]), 100 | null, 101 | null, 102 | null 103 | )) { 104 | justMe = loadContactsFrom(cursor); 105 | } 106 | } 107 | 108 | Map everyoneElse; 109 | { 110 | try (Cursor cursor = contentResolver.query( 111 | ContactsContract.Data.CONTENT_URI, 112 | FULL_PROJECTION.toArray(new String[FULL_PROJECTION.size()]), 113 | ContactsContract.Data.MIMETYPE + "=? OR " 114 | + ContactsContract.Data.MIMETYPE + "=? OR " 115 | + ContactsContract.Data.MIMETYPE + "=? OR " 116 | + ContactsContract.Data.MIMETYPE + "=? OR " 117 | + ContactsContract.Data.MIMETYPE + "=? OR " 118 | + ContactsContract.Data.MIMETYPE + "=? OR " 119 | + ContactsContract.Data.MIMETYPE + "=? OR " 120 | + ContactsContract.Data.MIMETYPE + "=? OR " 121 | + ContactsContract.Data.MIMETYPE + "=?", 122 | new String[]{ 123 | Email.CONTENT_ITEM_TYPE, 124 | Phone.CONTENT_ITEM_TYPE, 125 | StructuredName.CONTENT_ITEM_TYPE, 126 | Organization.CONTENT_ITEM_TYPE, 127 | StructuredPostal.CONTENT_ITEM_TYPE, 128 | Note.CONTENT_ITEM_TYPE, 129 | Website.CONTENT_ITEM_TYPE, 130 | Im.CONTENT_ITEM_TYPE, 131 | Event.CONTENT_ITEM_TYPE, 132 | }, 133 | null 134 | )) { 135 | everyoneElse = loadContactsFrom(cursor); 136 | } 137 | } 138 | 139 | justMe.putAll(everyoneElse); 140 | return justMe; 141 | } 142 | 143 | @NonNull 144 | private Map loadContactsFrom(Cursor cursor) { 145 | Map map = new LinkedHashMap<>(); 146 | 147 | while (cursor != null && cursor.moveToNext()) { 148 | int columnIndexContactId = cursor.getColumnIndex(ContactsContract.Data.CONTACT_ID); 149 | int columnIndexId = cursor.getColumnIndex(ContactsContract.Data._ID); 150 | int columnIndexRawContactId = cursor.getColumnIndex(ContactsContract.Data.RAW_CONTACT_ID); 151 | String contactId; 152 | String id; 153 | String rawContactId; 154 | if (columnIndexContactId != -1) { 155 | contactId = cursor.getString(columnIndexContactId); 156 | } else { 157 | //todo - double check this, it may not be necessary any more 158 | contactId = String.valueOf(ID_FOR_PROFILE_CONTACT);//no contact id for 'ME' user 159 | } 160 | 161 | if (columnIndexId != -1) { 162 | id = cursor.getString(columnIndexId); 163 | } else { 164 | //todo - double check this, it may not be necessary any more 165 | id = String.valueOf(ID_FOR_PROFILE_CONTACT);//no contact id for 'ME' user 166 | } 167 | 168 | if (columnIndexRawContactId != -1) { 169 | rawContactId = cursor.getString(columnIndexRawContactId); 170 | } else { 171 | //todo - double check this, it may not be necessary any more 172 | rawContactId = String.valueOf(ID_FOR_PROFILE_CONTACT);//no contact id for 'ME' user 173 | } 174 | 175 | if (!map.containsKey(contactId)) { 176 | map.put(contactId, new Contact(contactId)); 177 | } 178 | 179 | Contact contact = map.get(contactId); 180 | String mimeType = cursor.getString(cursor.getColumnIndex(ContactsContract.Data.MIMETYPE)); 181 | String name = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME)); 182 | contact.rawContactId = rawContactId; 183 | if (!TextUtils.isEmpty(name) && TextUtils.isEmpty(contact.displayName)) { 184 | contact.displayName = name; 185 | } 186 | 187 | if (TextUtils.isEmpty(contact.photoUri)) { 188 | String rawPhotoURI = cursor.getString(cursor.getColumnIndex(Contactables.PHOTO_URI)); 189 | if (!TextUtils.isEmpty(rawPhotoURI)) { 190 | contact.photoUri = rawPhotoURI; 191 | contact.hasPhoto = true; 192 | } 193 | } 194 | 195 | switch(mimeType) { 196 | case StructuredName.CONTENT_ITEM_TYPE: 197 | contact.givenName = cursor.getString(cursor.getColumnIndex(StructuredName.GIVEN_NAME)); 198 | if (cursor.getString(cursor.getColumnIndex(StructuredName.MIDDLE_NAME)) != null) { 199 | contact.middleName = cursor.getString(cursor.getColumnIndex(StructuredName.MIDDLE_NAME)); 200 | } else { 201 | contact.middleName = ""; 202 | } 203 | if (cursor.getString(cursor.getColumnIndex(StructuredName.FAMILY_NAME)) != null) { 204 | contact.familyName = cursor.getString(cursor.getColumnIndex(StructuredName.FAMILY_NAME)); 205 | } else { 206 | contact.familyName = ""; 207 | } 208 | contact.prefix = cursor.getString(cursor.getColumnIndex(StructuredName.PREFIX)); 209 | contact.suffix = cursor.getString(cursor.getColumnIndex(StructuredName.SUFFIX)); 210 | break; 211 | case Phone.CONTENT_ITEM_TYPE: 212 | String phoneNumber = cursor.getString(cursor.getColumnIndex(Phone.NUMBER)); 213 | int phoneType = cursor.getInt(cursor.getColumnIndex(Phone.TYPE)); 214 | 215 | if (!TextUtils.isEmpty(phoneNumber)) { 216 | String label; 217 | switch (phoneType) { 218 | case Phone.TYPE_HOME: 219 | label = "home"; 220 | break; 221 | case Phone.TYPE_WORK: 222 | label = "work"; 223 | break; 224 | case Phone.TYPE_MOBILE: 225 | label = "mobile"; 226 | break; 227 | case Phone.TYPE_OTHER: 228 | label = "other"; 229 | break; 230 | default: 231 | label = "other"; 232 | } 233 | contact.phones.add(new Contact.Item(label, phoneNumber, id)); 234 | } 235 | break; 236 | case Email.CONTENT_ITEM_TYPE: 237 | String email = cursor.getString(cursor.getColumnIndex(Email.ADDRESS)); 238 | int emailType = cursor.getInt(cursor.getColumnIndex(Email.TYPE)); 239 | if (!TextUtils.isEmpty(email)) { 240 | String label; 241 | switch (emailType) { 242 | case Email.TYPE_HOME: 243 | label = "home"; 244 | break; 245 | case Email.TYPE_WORK: 246 | label = "work"; 247 | break; 248 | case Email.TYPE_MOBILE: 249 | label = "mobile"; 250 | break; 251 | case Email.TYPE_OTHER: 252 | label = "other"; 253 | break; 254 | case Email.TYPE_CUSTOM: 255 | if (cursor.getString(cursor.getColumnIndex(Email.LABEL)) != null) { 256 | label = cursor.getString(cursor.getColumnIndex(Email.LABEL)).toLowerCase(); 257 | } else { 258 | label = ""; 259 | } 260 | break; 261 | default: 262 | label = "other"; 263 | } 264 | contact.emails.add(new Contact.Item(label, email, id)); 265 | } 266 | break; 267 | case Website.CONTENT_ITEM_TYPE: 268 | String url = cursor.getString(cursor.getColumnIndex(Website.URL)); 269 | int websiteType = cursor.getInt(cursor.getColumnIndex(Website.TYPE)); 270 | if (!TextUtils.isEmpty(url)) { 271 | String label; 272 | switch (websiteType) { 273 | case Website.TYPE_HOMEPAGE: 274 | label = "homepage"; 275 | break; 276 | case Website.TYPE_BLOG: 277 | label = "blog"; 278 | break; 279 | case Website.TYPE_PROFILE: 280 | label = "profile"; 281 | break; 282 | case Website.TYPE_HOME: 283 | label = "home"; 284 | break; 285 | case Website.TYPE_WORK: 286 | label = "work"; 287 | break; 288 | case Website.TYPE_FTP: 289 | label = "ftp"; 290 | break; 291 | case Website.TYPE_CUSTOM: 292 | if (cursor.getString(cursor.getColumnIndex(Website.LABEL)) != null) { 293 | label = cursor.getString(cursor.getColumnIndex(Website.LABEL)).toLowerCase(); 294 | } else { 295 | label = ""; 296 | } 297 | break; 298 | default: 299 | label = "other"; 300 | } 301 | contact.urls.add(new Contact.Item(label, url, id)); 302 | } 303 | break; 304 | case Im.CONTENT_ITEM_TYPE: 305 | String username = cursor.getString(cursor.getColumnIndex(Im.DATA)); 306 | int imType = cursor.getInt(cursor.getColumnIndex(Im.PROTOCOL)); 307 | if (!TextUtils.isEmpty(username)) { 308 | String label; 309 | switch (imType) { 310 | case Im.PROTOCOL_AIM: 311 | label = "AIM"; 312 | break; 313 | case Im.PROTOCOL_MSN: 314 | label = "MSN"; 315 | break; 316 | case Im.PROTOCOL_YAHOO: 317 | label = "Yahoo"; 318 | break; 319 | case Im.PROTOCOL_SKYPE: 320 | label = "Skype"; 321 | break; 322 | case Im.PROTOCOL_QQ: 323 | label = "QQ"; 324 | break; 325 | case Im.PROTOCOL_GOOGLE_TALK: 326 | label = "Google Talk"; 327 | break; 328 | case Im.PROTOCOL_ICQ: 329 | label = "ICQ"; 330 | break; 331 | case Im.PROTOCOL_JABBER: 332 | label = "Jabber"; 333 | break; 334 | case Im.PROTOCOL_NETMEETING: 335 | label = "NetMeeting"; 336 | break; 337 | case Im.PROTOCOL_CUSTOM: 338 | if (cursor.getString(cursor.getColumnIndex(Im.CUSTOM_PROTOCOL)) != null) { 339 | label = cursor.getString(cursor.getColumnIndex(Im.CUSTOM_PROTOCOL)); 340 | } else { 341 | label = ""; 342 | } 343 | break; 344 | default: 345 | label = "other"; 346 | } 347 | contact.instantMessengers.add(new Contact.Item(label, username, id)); 348 | } 349 | break; 350 | case Organization.CONTENT_ITEM_TYPE: 351 | contact.company = cursor.getString(cursor.getColumnIndex(Organization.COMPANY)); 352 | contact.jobTitle = cursor.getString(cursor.getColumnIndex(Organization.TITLE)); 353 | contact.department = cursor.getString(cursor.getColumnIndex(Organization.DEPARTMENT)); 354 | break; 355 | case StructuredPostal.CONTENT_ITEM_TYPE: 356 | contact.postalAddresses.add(Contact.PostalAddress.postalAddressFromCursor(cursor)); 357 | break; 358 | case Event.CONTENT_ITEM_TYPE: 359 | int eventType = cursor.getInt(cursor.getColumnIndex(Event.TYPE)); 360 | if (eventType == Event.TYPE_BIRTHDAY) { 361 | try { 362 | String birthday = cursor.getString(cursor.getColumnIndex(Event.START_DATE)).replace("--", ""); 363 | String[] yearMonthDay = birthday.split("-"); 364 | List yearMonthDayList = Arrays.asList(yearMonthDay); 365 | 366 | if (yearMonthDayList.size() == 2) { 367 | // birthday is formatted "12-31" 368 | int month = Integer.parseInt(yearMonthDayList.get(0)); 369 | int day = Integer.parseInt(yearMonthDayList.get(1)); 370 | if (month >= 1 && month <= 12 && day >= 1 && day <= 31) { 371 | contact.birthday = new Contact.Birthday(month, day); 372 | } 373 | } else if (yearMonthDayList.size() == 3) { 374 | // birthday is formatted "1986-12-31" 375 | int year = Integer.parseInt(yearMonthDayList.get(0)); 376 | int month = Integer.parseInt(yearMonthDayList.get(1)); 377 | int day = Integer.parseInt(yearMonthDayList.get(2)); 378 | if (year > 0 && month >= 1 && month <= 12 && day >= 1 && day <= 31) { 379 | contact.birthday = new Contact.Birthday(year, month, day); 380 | } 381 | } 382 | } catch (NumberFormatException | ArrayIndexOutOfBoundsException | NullPointerException e) { 383 | // whoops, birthday isn't in the format we expect 384 | Log.w("ContactsProvider", e.toString()); 385 | } 386 | } 387 | break; 388 | case Note.CONTENT_ITEM_TYPE: 389 | contact.note = cursor.getString(cursor.getColumnIndex(Note.NOTE)); 390 | break; 391 | } 392 | } 393 | 394 | return map; 395 | } 396 | 397 | @DoNotStrip 398 | public String getHash() throws NoSuchAlgorithmException { 399 | Map contacts = this.getContacts(); 400 | 401 | StringBuilder stringBuilder = new StringBuilder(); 402 | for (Map.Entry entry : contacts.entrySet()) { 403 | stringBuilder.append(entry.getValue().contactId); 404 | } 405 | MessageDigest digest = MessageDigest.getInstance("MD5"); 406 | digest.update(stringBuilder.toString().getBytes()); 407 | byte[] messageDigest = digest.digest(); 408 | 409 | // Create Hex String 410 | StringBuilder hexString = new StringBuilder(); 411 | for (byte b : messageDigest) { 412 | StringBuilder hex = new StringBuilder(Integer.toHexString(0xFF & b)); 413 | while (hex.length() < 2) 414 | hex.insert(0, "0"); 415 | hexString.append(hex); 416 | } 417 | return hexString.toString(); 418 | } 419 | } 420 | -------------------------------------------------------------------------------- /example/ios/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - boost-for-react-native (1.63.0) 3 | - CocoaAsyncSocket (7.6.5) 4 | - DoubleConversion (1.1.6) 5 | - FBLazyVector (0.65.1) 6 | - FBReactNativeSpec (0.65.1): 7 | - RCT-Folly (= 2021.04.26.00) 8 | - RCTRequired (= 0.65.1) 9 | - RCTTypeSafety (= 0.65.1) 10 | - React-Core (= 0.65.1) 11 | - React-jsi (= 0.65.1) 12 | - ReactCommon/turbomodule/core (= 0.65.1) 13 | - Flipper (0.93.0): 14 | - Flipper-Folly (~> 2.6) 15 | - Flipper-RSocket (~> 1.4) 16 | - Flipper-Boost-iOSX (1.76.0.1.11) 17 | - Flipper-DoubleConversion (3.1.7) 18 | - Flipper-Fmt (7.1.7) 19 | - Flipper-Folly (2.6.7): 20 | - Flipper-Boost-iOSX 21 | - Flipper-DoubleConversion 22 | - Flipper-Fmt (= 7.1.7) 23 | - Flipper-Glog 24 | - libevent (~> 2.1.12) 25 | - OpenSSL-Universal (= 1.1.180) 26 | - Flipper-Glog (0.3.6) 27 | - Flipper-PeerTalk (0.0.4) 28 | - Flipper-RSocket (1.4.3): 29 | - Flipper-Folly (~> 2.6) 30 | - FlipperKit (0.93.0): 31 | - FlipperKit/Core (= 0.93.0) 32 | - FlipperKit/Core (0.93.0): 33 | - Flipper (~> 0.93.0) 34 | - FlipperKit/CppBridge 35 | - FlipperKit/FBCxxFollyDynamicConvert 36 | - FlipperKit/FBDefines 37 | - FlipperKit/FKPortForwarding 38 | - FlipperKit/CppBridge (0.93.0): 39 | - Flipper (~> 0.93.0) 40 | - FlipperKit/FBCxxFollyDynamicConvert (0.93.0): 41 | - Flipper-Folly (~> 2.6) 42 | - FlipperKit/FBDefines (0.93.0) 43 | - FlipperKit/FKPortForwarding (0.93.0): 44 | - CocoaAsyncSocket (~> 7.6) 45 | - Flipper-PeerTalk (~> 0.0.4) 46 | - FlipperKit/FlipperKitHighlightOverlay (0.93.0) 47 | - FlipperKit/FlipperKitLayoutHelpers (0.93.0): 48 | - FlipperKit/Core 49 | - FlipperKit/FlipperKitHighlightOverlay 50 | - FlipperKit/FlipperKitLayoutTextSearchable 51 | - FlipperKit/FlipperKitLayoutIOSDescriptors (0.93.0): 52 | - FlipperKit/Core 53 | - FlipperKit/FlipperKitHighlightOverlay 54 | - FlipperKit/FlipperKitLayoutHelpers 55 | - YogaKit (~> 1.18) 56 | - FlipperKit/FlipperKitLayoutPlugin (0.93.0): 57 | - FlipperKit/Core 58 | - FlipperKit/FlipperKitHighlightOverlay 59 | - FlipperKit/FlipperKitLayoutHelpers 60 | - FlipperKit/FlipperKitLayoutIOSDescriptors 61 | - FlipperKit/FlipperKitLayoutTextSearchable 62 | - YogaKit (~> 1.18) 63 | - FlipperKit/FlipperKitLayoutTextSearchable (0.93.0) 64 | - FlipperKit/FlipperKitNetworkPlugin (0.93.0): 65 | - FlipperKit/Core 66 | - FlipperKit/FlipperKitReactPlugin (0.93.0): 67 | - FlipperKit/Core 68 | - FlipperKit/FlipperKitUserDefaultsPlugin (0.93.0): 69 | - FlipperKit/Core 70 | - FlipperKit/SKIOSNetworkPlugin (0.93.0): 71 | - FlipperKit/Core 72 | - FlipperKit/FlipperKitNetworkPlugin 73 | - fmt (6.2.1) 74 | - glog (0.3.5) 75 | - libevent (2.1.12) 76 | - OpenSSL-Universal (1.1.180) 77 | - RCT-Folly (2021.04.26.00): 78 | - boost-for-react-native 79 | - DoubleConversion 80 | - fmt (~> 6.2.1) 81 | - glog 82 | - RCT-Folly/Default (= 2021.04.26.00) 83 | - RCT-Folly/Default (2021.04.26.00): 84 | - boost-for-react-native 85 | - DoubleConversion 86 | - fmt (~> 6.2.1) 87 | - glog 88 | - RCTRequired (0.65.1) 89 | - RCTTypeSafety (0.65.1): 90 | - FBLazyVector (= 0.65.1) 91 | - RCT-Folly (= 2021.04.26.00) 92 | - RCTRequired (= 0.65.1) 93 | - React-Core (= 0.65.1) 94 | - React (0.65.1): 95 | - React-Core (= 0.65.1) 96 | - React-Core/DevSupport (= 0.65.1) 97 | - React-Core/RCTWebSocket (= 0.65.1) 98 | - React-RCTActionSheet (= 0.65.1) 99 | - React-RCTAnimation (= 0.65.1) 100 | - React-RCTBlob (= 0.65.1) 101 | - React-RCTImage (= 0.65.1) 102 | - React-RCTLinking (= 0.65.1) 103 | - React-RCTNetwork (= 0.65.1) 104 | - React-RCTSettings (= 0.65.1) 105 | - React-RCTText (= 0.65.1) 106 | - React-RCTVibration (= 0.65.1) 107 | - React-callinvoker (0.65.1) 108 | - React-Core (0.65.1): 109 | - glog 110 | - RCT-Folly (= 2021.04.26.00) 111 | - React-Core/Default (= 0.65.1) 112 | - React-cxxreact (= 0.65.1) 113 | - React-jsi (= 0.65.1) 114 | - React-jsiexecutor (= 0.65.1) 115 | - React-perflogger (= 0.65.1) 116 | - Yoga 117 | - React-Core/CoreModulesHeaders (0.65.1): 118 | - glog 119 | - RCT-Folly (= 2021.04.26.00) 120 | - React-Core/Default 121 | - React-cxxreact (= 0.65.1) 122 | - React-jsi (= 0.65.1) 123 | - React-jsiexecutor (= 0.65.1) 124 | - React-perflogger (= 0.65.1) 125 | - Yoga 126 | - React-Core/Default (0.65.1): 127 | - glog 128 | - RCT-Folly (= 2021.04.26.00) 129 | - React-cxxreact (= 0.65.1) 130 | - React-jsi (= 0.65.1) 131 | - React-jsiexecutor (= 0.65.1) 132 | - React-perflogger (= 0.65.1) 133 | - Yoga 134 | - React-Core/DevSupport (0.65.1): 135 | - glog 136 | - RCT-Folly (= 2021.04.26.00) 137 | - React-Core/Default (= 0.65.1) 138 | - React-Core/RCTWebSocket (= 0.65.1) 139 | - React-cxxreact (= 0.65.1) 140 | - React-jsi (= 0.65.1) 141 | - React-jsiexecutor (= 0.65.1) 142 | - React-jsinspector (= 0.65.1) 143 | - React-perflogger (= 0.65.1) 144 | - Yoga 145 | - React-Core/RCTActionSheetHeaders (0.65.1): 146 | - glog 147 | - RCT-Folly (= 2021.04.26.00) 148 | - React-Core/Default 149 | - React-cxxreact (= 0.65.1) 150 | - React-jsi (= 0.65.1) 151 | - React-jsiexecutor (= 0.65.1) 152 | - React-perflogger (= 0.65.1) 153 | - Yoga 154 | - React-Core/RCTAnimationHeaders (0.65.1): 155 | - glog 156 | - RCT-Folly (= 2021.04.26.00) 157 | - React-Core/Default 158 | - React-cxxreact (= 0.65.1) 159 | - React-jsi (= 0.65.1) 160 | - React-jsiexecutor (= 0.65.1) 161 | - React-perflogger (= 0.65.1) 162 | - Yoga 163 | - React-Core/RCTBlobHeaders (0.65.1): 164 | - glog 165 | - RCT-Folly (= 2021.04.26.00) 166 | - React-Core/Default 167 | - React-cxxreact (= 0.65.1) 168 | - React-jsi (= 0.65.1) 169 | - React-jsiexecutor (= 0.65.1) 170 | - React-perflogger (= 0.65.1) 171 | - Yoga 172 | - React-Core/RCTImageHeaders (0.65.1): 173 | - glog 174 | - RCT-Folly (= 2021.04.26.00) 175 | - React-Core/Default 176 | - React-cxxreact (= 0.65.1) 177 | - React-jsi (= 0.65.1) 178 | - React-jsiexecutor (= 0.65.1) 179 | - React-perflogger (= 0.65.1) 180 | - Yoga 181 | - React-Core/RCTLinkingHeaders (0.65.1): 182 | - glog 183 | - RCT-Folly (= 2021.04.26.00) 184 | - React-Core/Default 185 | - React-cxxreact (= 0.65.1) 186 | - React-jsi (= 0.65.1) 187 | - React-jsiexecutor (= 0.65.1) 188 | - React-perflogger (= 0.65.1) 189 | - Yoga 190 | - React-Core/RCTNetworkHeaders (0.65.1): 191 | - glog 192 | - RCT-Folly (= 2021.04.26.00) 193 | - React-Core/Default 194 | - React-cxxreact (= 0.65.1) 195 | - React-jsi (= 0.65.1) 196 | - React-jsiexecutor (= 0.65.1) 197 | - React-perflogger (= 0.65.1) 198 | - Yoga 199 | - React-Core/RCTSettingsHeaders (0.65.1): 200 | - glog 201 | - RCT-Folly (= 2021.04.26.00) 202 | - React-Core/Default 203 | - React-cxxreact (= 0.65.1) 204 | - React-jsi (= 0.65.1) 205 | - React-jsiexecutor (= 0.65.1) 206 | - React-perflogger (= 0.65.1) 207 | - Yoga 208 | - React-Core/RCTTextHeaders (0.65.1): 209 | - glog 210 | - RCT-Folly (= 2021.04.26.00) 211 | - React-Core/Default 212 | - React-cxxreact (= 0.65.1) 213 | - React-jsi (= 0.65.1) 214 | - React-jsiexecutor (= 0.65.1) 215 | - React-perflogger (= 0.65.1) 216 | - Yoga 217 | - React-Core/RCTVibrationHeaders (0.65.1): 218 | - glog 219 | - RCT-Folly (= 2021.04.26.00) 220 | - React-Core/Default 221 | - React-cxxreact (= 0.65.1) 222 | - React-jsi (= 0.65.1) 223 | - React-jsiexecutor (= 0.65.1) 224 | - React-perflogger (= 0.65.1) 225 | - Yoga 226 | - React-Core/RCTWebSocket (0.65.1): 227 | - glog 228 | - RCT-Folly (= 2021.04.26.00) 229 | - React-Core/Default (= 0.65.1) 230 | - React-cxxreact (= 0.65.1) 231 | - React-jsi (= 0.65.1) 232 | - React-jsiexecutor (= 0.65.1) 233 | - React-perflogger (= 0.65.1) 234 | - Yoga 235 | - React-CoreModules (0.65.1): 236 | - FBReactNativeSpec (= 0.65.1) 237 | - RCT-Folly (= 2021.04.26.00) 238 | - RCTTypeSafety (= 0.65.1) 239 | - React-Core/CoreModulesHeaders (= 0.65.1) 240 | - React-jsi (= 0.65.1) 241 | - React-RCTImage (= 0.65.1) 242 | - ReactCommon/turbomodule/core (= 0.65.1) 243 | - React-cxxreact (0.65.1): 244 | - boost-for-react-native (= 1.63.0) 245 | - DoubleConversion 246 | - glog 247 | - RCT-Folly (= 2021.04.26.00) 248 | - React-callinvoker (= 0.65.1) 249 | - React-jsi (= 0.65.1) 250 | - React-jsinspector (= 0.65.1) 251 | - React-perflogger (= 0.65.1) 252 | - React-runtimeexecutor (= 0.65.1) 253 | - React-jsi (0.65.1): 254 | - boost-for-react-native (= 1.63.0) 255 | - DoubleConversion 256 | - glog 257 | - RCT-Folly (= 2021.04.26.00) 258 | - React-jsi/Default (= 0.65.1) 259 | - React-jsi/Default (0.65.1): 260 | - boost-for-react-native (= 1.63.0) 261 | - DoubleConversion 262 | - glog 263 | - RCT-Folly (= 2021.04.26.00) 264 | - React-jsiexecutor (0.65.1): 265 | - DoubleConversion 266 | - glog 267 | - RCT-Folly (= 2021.04.26.00) 268 | - React-cxxreact (= 0.65.1) 269 | - React-jsi (= 0.65.1) 270 | - React-perflogger (= 0.65.1) 271 | - React-jsinspector (0.65.1) 272 | - react-native-contacts (7.0.2): 273 | - React-Core 274 | - react-native-jsi-contacts (0.1.2): 275 | - React-Core 276 | - React-perflogger (0.65.1) 277 | - React-RCTActionSheet (0.65.1): 278 | - React-Core/RCTActionSheetHeaders (= 0.65.1) 279 | - React-RCTAnimation (0.65.1): 280 | - FBReactNativeSpec (= 0.65.1) 281 | - RCT-Folly (= 2021.04.26.00) 282 | - RCTTypeSafety (= 0.65.1) 283 | - React-Core/RCTAnimationHeaders (= 0.65.1) 284 | - React-jsi (= 0.65.1) 285 | - ReactCommon/turbomodule/core (= 0.65.1) 286 | - React-RCTBlob (0.65.1): 287 | - FBReactNativeSpec (= 0.65.1) 288 | - RCT-Folly (= 2021.04.26.00) 289 | - React-Core/RCTBlobHeaders (= 0.65.1) 290 | - React-Core/RCTWebSocket (= 0.65.1) 291 | - React-jsi (= 0.65.1) 292 | - React-RCTNetwork (= 0.65.1) 293 | - ReactCommon/turbomodule/core (= 0.65.1) 294 | - React-RCTImage (0.65.1): 295 | - FBReactNativeSpec (= 0.65.1) 296 | - RCT-Folly (= 2021.04.26.00) 297 | - RCTTypeSafety (= 0.65.1) 298 | - React-Core/RCTImageHeaders (= 0.65.1) 299 | - React-jsi (= 0.65.1) 300 | - React-RCTNetwork (= 0.65.1) 301 | - ReactCommon/turbomodule/core (= 0.65.1) 302 | - React-RCTLinking (0.65.1): 303 | - FBReactNativeSpec (= 0.65.1) 304 | - React-Core/RCTLinkingHeaders (= 0.65.1) 305 | - React-jsi (= 0.65.1) 306 | - ReactCommon/turbomodule/core (= 0.65.1) 307 | - React-RCTNetwork (0.65.1): 308 | - FBReactNativeSpec (= 0.65.1) 309 | - RCT-Folly (= 2021.04.26.00) 310 | - RCTTypeSafety (= 0.65.1) 311 | - React-Core/RCTNetworkHeaders (= 0.65.1) 312 | - React-jsi (= 0.65.1) 313 | - ReactCommon/turbomodule/core (= 0.65.1) 314 | - React-RCTSettings (0.65.1): 315 | - FBReactNativeSpec (= 0.65.1) 316 | - RCT-Folly (= 2021.04.26.00) 317 | - RCTTypeSafety (= 0.65.1) 318 | - React-Core/RCTSettingsHeaders (= 0.65.1) 319 | - React-jsi (= 0.65.1) 320 | - ReactCommon/turbomodule/core (= 0.65.1) 321 | - React-RCTText (0.65.1): 322 | - React-Core/RCTTextHeaders (= 0.65.1) 323 | - React-RCTVibration (0.65.1): 324 | - FBReactNativeSpec (= 0.65.1) 325 | - RCT-Folly (= 2021.04.26.00) 326 | - React-Core/RCTVibrationHeaders (= 0.65.1) 327 | - React-jsi (= 0.65.1) 328 | - ReactCommon/turbomodule/core (= 0.65.1) 329 | - React-runtimeexecutor (0.65.1): 330 | - React-jsi (= 0.65.1) 331 | - ReactCommon/turbomodule/core (0.65.1): 332 | - DoubleConversion 333 | - glog 334 | - RCT-Folly (= 2021.04.26.00) 335 | - React-callinvoker (= 0.65.1) 336 | - React-Core (= 0.65.1) 337 | - React-cxxreact (= 0.65.1) 338 | - React-jsi (= 0.65.1) 339 | - React-perflogger (= 0.65.1) 340 | - RNPermissions (3.0.5): 341 | - React-Core 342 | - Yoga (1.14.0) 343 | - YogaKit (1.18.1): 344 | - Yoga (~> 1.14) 345 | 346 | DEPENDENCIES: 347 | - DoubleConversion (from `../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`) 348 | - FBLazyVector (from `../node_modules/react-native/Libraries/FBLazyVector`) 349 | - FBReactNativeSpec (from `../node_modules/react-native/React/FBReactNativeSpec`) 350 | - Flipper (= 0.93.0) 351 | - Flipper-Boost-iOSX (= 1.76.0.1.11) 352 | - Flipper-DoubleConversion (= 3.1.7) 353 | - Flipper-Fmt (= 7.1.7) 354 | - Flipper-Folly (= 2.6.7) 355 | - Flipper-Glog (= 0.3.6) 356 | - Flipper-PeerTalk (= 0.0.4) 357 | - Flipper-RSocket (= 1.4.3) 358 | - FlipperKit (= 0.93.0) 359 | - FlipperKit/Core (= 0.93.0) 360 | - FlipperKit/CppBridge (= 0.93.0) 361 | - FlipperKit/FBCxxFollyDynamicConvert (= 0.93.0) 362 | - FlipperKit/FBDefines (= 0.93.0) 363 | - FlipperKit/FKPortForwarding (= 0.93.0) 364 | - FlipperKit/FlipperKitHighlightOverlay (= 0.93.0) 365 | - FlipperKit/FlipperKitLayoutPlugin (= 0.93.0) 366 | - FlipperKit/FlipperKitLayoutTextSearchable (= 0.93.0) 367 | - FlipperKit/FlipperKitNetworkPlugin (= 0.93.0) 368 | - FlipperKit/FlipperKitReactPlugin (= 0.93.0) 369 | - FlipperKit/FlipperKitUserDefaultsPlugin (= 0.93.0) 370 | - FlipperKit/SKIOSNetworkPlugin (= 0.93.0) 371 | - glog (from `../node_modules/react-native/third-party-podspecs/glog.podspec`) 372 | - RCT-Folly (from `../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec`) 373 | - RCTRequired (from `../node_modules/react-native/Libraries/RCTRequired`) 374 | - RCTTypeSafety (from `../node_modules/react-native/Libraries/TypeSafety`) 375 | - React (from `../node_modules/react-native/`) 376 | - React-callinvoker (from `../node_modules/react-native/ReactCommon/callinvoker`) 377 | - React-Core (from `../node_modules/react-native/`) 378 | - React-Core/DevSupport (from `../node_modules/react-native/`) 379 | - React-Core/RCTWebSocket (from `../node_modules/react-native/`) 380 | - React-CoreModules (from `../node_modules/react-native/React/CoreModules`) 381 | - React-cxxreact (from `../node_modules/react-native/ReactCommon/cxxreact`) 382 | - React-jsi (from `../node_modules/react-native/ReactCommon/jsi`) 383 | - React-jsiexecutor (from `../node_modules/react-native/ReactCommon/jsiexecutor`) 384 | - React-jsinspector (from `../node_modules/react-native/ReactCommon/jsinspector`) 385 | - react-native-contacts (from `../node_modules/react-native-contacts`) 386 | - react-native-jsi-contacts (from `../..`) 387 | - React-perflogger (from `../node_modules/react-native/ReactCommon/reactperflogger`) 388 | - React-RCTActionSheet (from `../node_modules/react-native/Libraries/ActionSheetIOS`) 389 | - React-RCTAnimation (from `../node_modules/react-native/Libraries/NativeAnimation`) 390 | - React-RCTBlob (from `../node_modules/react-native/Libraries/Blob`) 391 | - React-RCTImage (from `../node_modules/react-native/Libraries/Image`) 392 | - React-RCTLinking (from `../node_modules/react-native/Libraries/LinkingIOS`) 393 | - React-RCTNetwork (from `../node_modules/react-native/Libraries/Network`) 394 | - React-RCTSettings (from `../node_modules/react-native/Libraries/Settings`) 395 | - React-RCTText (from `../node_modules/react-native/Libraries/Text`) 396 | - React-RCTVibration (from `../node_modules/react-native/Libraries/Vibration`) 397 | - React-runtimeexecutor (from `../node_modules/react-native/ReactCommon/runtimeexecutor`) 398 | - ReactCommon/turbomodule/core (from `../node_modules/react-native/ReactCommon`) 399 | - RNPermissions (from `../node_modules/react-native-permissions`) 400 | - Yoga (from `../node_modules/react-native/ReactCommon/yoga`) 401 | 402 | SPEC REPOS: 403 | trunk: 404 | - boost-for-react-native 405 | - CocoaAsyncSocket 406 | - Flipper 407 | - Flipper-Boost-iOSX 408 | - Flipper-DoubleConversion 409 | - Flipper-Fmt 410 | - Flipper-Folly 411 | - Flipper-Glog 412 | - Flipper-PeerTalk 413 | - Flipper-RSocket 414 | - FlipperKit 415 | - fmt 416 | - libevent 417 | - OpenSSL-Universal 418 | - YogaKit 419 | 420 | EXTERNAL SOURCES: 421 | DoubleConversion: 422 | :podspec: "../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec" 423 | FBLazyVector: 424 | :path: "../node_modules/react-native/Libraries/FBLazyVector" 425 | FBReactNativeSpec: 426 | :path: "../node_modules/react-native/React/FBReactNativeSpec" 427 | glog: 428 | :podspec: "../node_modules/react-native/third-party-podspecs/glog.podspec" 429 | RCT-Folly: 430 | :podspec: "../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec" 431 | RCTRequired: 432 | :path: "../node_modules/react-native/Libraries/RCTRequired" 433 | RCTTypeSafety: 434 | :path: "../node_modules/react-native/Libraries/TypeSafety" 435 | React: 436 | :path: "../node_modules/react-native/" 437 | React-callinvoker: 438 | :path: "../node_modules/react-native/ReactCommon/callinvoker" 439 | React-Core: 440 | :path: "../node_modules/react-native/" 441 | React-CoreModules: 442 | :path: "../node_modules/react-native/React/CoreModules" 443 | React-cxxreact: 444 | :path: "../node_modules/react-native/ReactCommon/cxxreact" 445 | React-jsi: 446 | :path: "../node_modules/react-native/ReactCommon/jsi" 447 | React-jsiexecutor: 448 | :path: "../node_modules/react-native/ReactCommon/jsiexecutor" 449 | React-jsinspector: 450 | :path: "../node_modules/react-native/ReactCommon/jsinspector" 451 | react-native-contacts: 452 | :path: "../node_modules/react-native-contacts" 453 | react-native-jsi-contacts: 454 | :path: "../.." 455 | React-perflogger: 456 | :path: "../node_modules/react-native/ReactCommon/reactperflogger" 457 | React-RCTActionSheet: 458 | :path: "../node_modules/react-native/Libraries/ActionSheetIOS" 459 | React-RCTAnimation: 460 | :path: "../node_modules/react-native/Libraries/NativeAnimation" 461 | React-RCTBlob: 462 | :path: "../node_modules/react-native/Libraries/Blob" 463 | React-RCTImage: 464 | :path: "../node_modules/react-native/Libraries/Image" 465 | React-RCTLinking: 466 | :path: "../node_modules/react-native/Libraries/LinkingIOS" 467 | React-RCTNetwork: 468 | :path: "../node_modules/react-native/Libraries/Network" 469 | React-RCTSettings: 470 | :path: "../node_modules/react-native/Libraries/Settings" 471 | React-RCTText: 472 | :path: "../node_modules/react-native/Libraries/Text" 473 | React-RCTVibration: 474 | :path: "../node_modules/react-native/Libraries/Vibration" 475 | React-runtimeexecutor: 476 | :path: "../node_modules/react-native/ReactCommon/runtimeexecutor" 477 | ReactCommon: 478 | :path: "../node_modules/react-native/ReactCommon" 479 | RNPermissions: 480 | :path: "../node_modules/react-native-permissions" 481 | Yoga: 482 | :path: "../node_modules/react-native/ReactCommon/yoga" 483 | 484 | SPEC CHECKSUMS: 485 | boost-for-react-native: 39c7adb57c4e60d6c5479dd8623128eb5b3f0f2c 486 | CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99 487 | DoubleConversion: cde416483dac037923206447da6e1454df403714 488 | FBLazyVector: 33c82491102f20ecddb6c6a2c273696ace3191e0 489 | FBReactNativeSpec: df8f81d2a7541ee6755a047b398a5cb5a72acd0e 490 | Flipper: b1fddf9a17c32097b2b4c806ad158b2f36bb2692 491 | Flipper-Boost-iOSX: fd1e2b8cbef7e662a122412d7ac5f5bea715403c 492 | Flipper-DoubleConversion: 57ffbe81ef95306cc9e69c4aa3aeeeeb58a6a28c 493 | Flipper-Fmt: 60cbdd92fc254826e61d669a5d87ef7015396a9b 494 | Flipper-Folly: 83af37379faa69497529e414bd43fbfc7cae259a 495 | Flipper-Glog: 1dfd6abf1e922806c52ceb8701a3599a79a200a6 496 | Flipper-PeerTalk: 116d8f857dc6ef55c7a5a75ea3ceaafe878aadc9 497 | Flipper-RSocket: d9d9ade67cbecf6ac10730304bf5607266dd2541 498 | FlipperKit: aec2d931adeee48a07bab1ea8bcc8a6bb87dfce4 499 | fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9 500 | glog: 40a13f7840415b9a77023fbcae0f1e6f43192af3 501 | libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913 502 | OpenSSL-Universal: 1aa4f6a6ee7256b83db99ec1ccdaa80d10f9af9b 503 | RCT-Folly: 0dd9e1eb86348ecab5ba76f910b56f4b5fef3c46 504 | RCTRequired: 6cf071ab2adfd769014b3d94373744ee6e789530 505 | RCTTypeSafety: b829c59453478bb5b02487b8de3336386ab93ab1 506 | React: 29d8a785041b96a2754c25cc16ddea57b7a618ce 507 | React-callinvoker: 2857b61132bd7878b736e282581f4b42fd93002b 508 | React-Core: 001e21bad5ca41e59e9d90df5c0b53da04c3ce8e 509 | React-CoreModules: 0a0410ab296a62ab38e2f8d321e822d1fcc2fe49 510 | React-cxxreact: 8d904967134ae8ff0119c5357c42eaae976806f8 511 | React-jsi: 12913c841713a15f64eabf5c9ad98592c0ec5940 512 | React-jsiexecutor: 43f2542aed3c26e42175b339f8d37fe3dd683765 513 | React-jsinspector: 41e58e5b8e3e0bf061fdf725b03f2144014a8fb0 514 | react-native-contacts: bc424db19c3384e44e6a9d9da9a78ee51b0aa7a1 515 | react-native-jsi-contacts: a55784b8ccc7e4d8c326ffabccb1f7493fe10848 516 | React-perflogger: fd28ee1f2b5b150b00043f0301d96bd417fdc339 517 | React-RCTActionSheet: 7f3fa0855c346aa5d7c60f9ced16e067db6d29fa 518 | React-RCTAnimation: 2119a18ee26159004b001bc56404ca5dbaae6077 519 | React-RCTBlob: a493cc306deeaba0c0efa8ecec2da154afd3a798 520 | React-RCTImage: 54999ddc896b7db6650af5760607aaebdf30425c 521 | React-RCTLinking: 7fb3fa6397d3700c69c3d361870a299f04f1a2e6 522 | React-RCTNetwork: 329ee4f75bd2deb8cf6c4b14231b5bb272cbd9af 523 | React-RCTSettings: 1a659d58e45719bc77c280dbebce6a5a5a2733f5 524 | React-RCTText: e12d7aae2a038be9ae72815436677a7c6549dd26 525 | React-RCTVibration: 92d41c2442e5328cc4d342cd7f78e5876b68bae5 526 | React-runtimeexecutor: 85187f19dd9c47a7c102f9994f9d14e4dc2110de 527 | ReactCommon: eafed38eec7b591c31751bfa7494801618460459 528 | RNPermissions: 7043bacbf928eae25808275cfe73799b8f618911 529 | Yoga: aa0cb45287ebe1004c02a13f279c55a95f1572f4 530 | YogaKit: f782866e155069a2cca2517aafea43200b01fd5a 531 | 532 | PODFILE CHECKSUM: 3160cb0b6a49bd8af1c299be4134e66317aa61c9 533 | 534 | COCOAPODS: 1.10.2 535 | --------------------------------------------------------------------------------