Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

add share intent support (ios)

ammarahm-ed4bcf458b4dcd
diff --git a/apps/mobile/App.js b/apps/mobile/App.js
index 3ad3a796d..d771ac354 100644
--- a/apps/mobile/App.js
+++ b/apps/mobile/App.js
@@ -32,7 +32,6 @@ import Backup from './src/services/Backup';
import {setLoginMessage} from './src/services/Message';
import SplashScreen from 'react-native-splash-screen';
import {sortSettings} from './src/utils';
-import Database from 'notes-core/api';
let firstLoad = true;
let note = null;
diff --git a/apps/mobile/html/Web.bundle/site/listeners.js b/apps/mobile/html/Web.bundle/site/listeners.js
index 500d07aac..e580ddb02 100644
--- a/apps/mobile/html/Web.bundle/site/listeners.js
+++ b/apps/mobile/html/Web.bundle/site/listeners.js
@@ -147,9 +147,7 @@ function attachEditorListeners() {
const content = value
editor.setContents(content, 'api');
- setTimeout(() => {
- //editor.setSelection(editor.getText().length - 1, 0);
- }, 500)
+
break;
case "html":
@@ -157,9 +155,6 @@ function attachEditorListeners() {
editor.clipboard.convert(value, 'api'),
'silent'
);
- setTimeout(() => {
- //editor.setSelection(editor.getText().length - 1, 0);
- }, 0);
break;
default:
break;
diff --git a/apps/mobile/ios/Add to Notes/Add to Notes.entitlements b/apps/mobile/ios/Add to Notes/Add to Notes.entitlements
new file mode 100644
index 000000000..f8f0c6240
--- /dev/null
+++ b/apps/mobile/ios/Add to Notes/Add to Notes.entitlements
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>com.apple.security.application-groups</key>
+ <array>
+ <string>group.org.reactjs.native.example.Notesnook</string>
+ </array>
+</dict>
+</plist>
diff --git a/apps/mobile/ios/Add to Notes/Base.lproj/MainInterface.storyboard b/apps/mobile/ios/Add to Notes/Base.lproj/MainInterface.storyboard
new file mode 100644
index 000000000..286a50894
--- /dev/null
+++ b/apps/mobile/ios/Add to Notes/Base.lproj/MainInterface.storyboard
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="j1y-V4-xli">
+ <dependencies>
+ <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
+ <capability name="Safe area layout guides" minToolsVersion="9.0"/>
+ <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
+ </dependencies>
+ <scenes>
+ <!--Share View Controller-->
+ <scene sceneID="ceB-am-kn3">
+ <objects>
+ <viewController id="j1y-V4-xli" customClass="ShareViewController" customModuleProvider="target" sceneMemberID="viewController">
+ <view key="view" opaque="NO" contentMode="scaleToFill" id="wbc-yd-nQP">
+ <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
+ <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+ <color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
+ <viewLayoutGuide key="safeArea" id="1Xd-am-t49"/>
+ </view>
+ </viewController>
+ <placeholder placeholderIdentifier="IBFirstResponder" id="CEy-Cv-SGf" userLabel="First Responder" sceneMemberID="firstResponder"/>
+ </objects>
+ </scene>
+ </scenes>
+</document>
diff --git a/apps/mobile/ios/Add to Notes/Info.plist b/apps/mobile/ios/Add to Notes/Info.plist
new file mode 100644
index 000000000..203b9e493
--- /dev/null
+++ b/apps/mobile/ios/Add to Notes/Info.plist
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>$(DEVELOPMENT_LANGUAGE)</string>
+ <key>CFBundleDisplayName</key>
+ <string>Add to Notes</string>
+ <key>CFBundleExecutable</key>
+ <string>$(EXECUTABLE_NAME)</string>
+ <key>CFBundleIdentifier</key>
+ <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundleName</key>
+ <string>$(PRODUCT_NAME)</string>
+ <key>CFBundlePackageType</key>
+ <string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
+ <key>CFBundleShortVersionString</key>
+ <string>1.0</string>
+ <key>CFBundleVersion</key>
+ <string>1</string>
+ <key>NSExtension</key>
+ <dict>
+ <key>NSExtensionAttributes</key>
+ <dict>
+ <key>NSExtensionActivationRule</key>
+ <dict>
+ <!--TODO: Add this flag, if you want to support sharing text into your app-->
+ <key>NSExtensionActivationSupportsText</key>
+ <true/>
+ <!--TODO: Add this tag, if you want to support sharing urls into your app-->
+ <key>NSExtensionActivationSupportsWebURLWithMaxCount</key>
+ <integer>1</integer>
+ </dict>
+ </dict>
+ <key>NSExtensionMainStoryboard</key>
+ <string>MainInterface</string>
+ <key>NSExtensionPointIdentifier</key>
+ <string>com.apple.share-services</string>
+ </dict>
+</dict>
+</plist>
diff --git a/apps/mobile/ios/Add to Notes/ShareViewController.swift b/apps/mobile/ios/Add to Notes/ShareViewController.swift
new file mode 100644
index 000000000..3b00723ab
--- /dev/null
+++ b/apps/mobile/ios/Add to Notes/ShareViewController.swift
@@ -0,0 +1,335 @@
+import UIKit
+import Social
+import MobileCoreServices
+import Photos
+
+class ShareViewController: SLComposeServiceViewController {
+ // TODO: IMPORTANT: This should be your host app bundle identifier
+ let hostAppBundleIdentifier = "org.reactjs.native.example.Notesnook"
+ let sharedKey = "ShareKey"
+ var sharedMedia: [SharedMediaFile] = []
+ var sharedText: [String] = []
+ let imageContentType = kUTTypeImage as String
+ let videoContentType = kUTTypeMovie as String
+ let textContentType = kUTTypeText as String
+ let urlContentType = kUTTypeURL as String
+ let fileURLType = kUTTypeFileURL as String;
+
+ override func isContentValid() -> Bool {
+ return true
+ }
+
+ override func viewDidLoad() {
+ cancel()
+ runSelectPost()
+ }
+
+ //override func didSelectPost() {
+ func runSelectPost() {
+ // This is called after the user selects Post. Do the upload of contentText and/or NSExtensionContext attachments.
+ if let content = extensionContext!.inputItems[0] as? NSExtensionItem {
+ if let contents = content.attachments {
+ for (index, attachment) in (contents).enumerated() {
+ if attachment.hasItemConformingToTypeIdentifier(imageContentType) {
+ handleImages(content: content, attachment: attachment, index: index)
+ } else if attachment.hasItemConformingToTypeIdentifier(textContentType) {
+ handleText(content: content, attachment: attachment, index: index)
+ } else if attachment.hasItemConformingToTypeIdentifier(fileURLType) {
+ handleFiles(content: content, attachment: attachment, index: index)
+ } else if attachment.hasItemConformingToTypeIdentifier(urlContentType) {
+ handleUrl(content: content, attachment: attachment, index: index)
+ } else if attachment.hasItemConformingToTypeIdentifier(videoContentType) {
+ handleVideos(content: content, attachment: attachment, index: index)
+ }
+ }
+ }
+ }
+ }
+
+ override func configurationItems() -> [Any]! {
+ // To add configuration options via table cells at the bottom of the sheet, return an array of SLComposeSheetConfigurationItem here.
+ return []
+ }
+
+ private func handleText (content: NSExtensionItem, attachment: NSItemProvider, index: Int) {
+ attachment.loadItem(forTypeIdentifier: textContentType, options: nil) { [weak self] data, error in
+
+ if error == nil, let item = data as? String, let this = self {
+
+ this.sharedText.append(item)
+
+ // If this is the last item, save imagesData in userDefaults and redirect to host app
+ if index == (content.attachments?.count)! - 1 {
+ let userDefaults = UserDefaults(suiteName: "group.\(this.hostAppBundleIdentifier)")
+ userDefaults?.set(this.sharedText, forKey: this.sharedKey)
+ userDefaults?.synchronize()
+ this.redirectToHostApp(type: .text)
+
+ }
+
+ } else {
+ self?.dismissWithError()
+ }
+ }
+ }
+
+ private func handleUrl (content: NSExtensionItem, attachment: NSItemProvider, index: Int) {
+ attachment.loadItem(forTypeIdentifier: urlContentType, options: nil) { [weak self] data, error in
+
+ if error == nil, let item = data as? URL, let this = self {
+
+ this.sharedText.append(item.absoluteString)
+
+ // If this is the last item, save imagesData in userDefaults and redirect to host app
+ if index == (content.attachments?.count)! - 1 {
+ let userDefaults = UserDefaults(suiteName: "group.\(this.hostAppBundleIdentifier)")
+ userDefaults?.set(this.sharedText, forKey: this.sharedKey)
+ userDefaults?.synchronize()
+ this.redirectToHostApp(type: .text)
+ }
+
+ } else {
+ self?.dismissWithError()
+ }
+ }
+ }
+
+ private func handleImages (content: NSExtensionItem, attachment: NSItemProvider, index: Int) {
+ attachment.loadItem(forTypeIdentifier: imageContentType, options: nil) { [weak self] data, error in
+
+ if error == nil, let url = data as? URL, let this = self {
+ // this.redirectToHostApp(type: .media)
+ // Always copy
+ let fileExtension = this.getExtension(from: url, type: .video)
+ let newName = UUID().uuidString
+ let newPath = FileManager.default
+ .containerURL(forSecurityApplicationGroupIdentifier: "group.\(this.hostAppBundleIdentifier)")!
+ .appendingPathComponent("\(newName).\(fileExtension)")
+ let copied = this.copyFile(at: url, to: newPath)
+ if(copied) {
+ this.sharedMedia.append(SharedMediaFile(path: newPath.absoluteString, thumbnail: nil, duration: nil, type: .image))
+ }
+
+ // If this is the last item, save imagesData in userDefaults and redirect to host app
+ if index == (content.attachments?.count)! - 1 {
+ let userDefaults = UserDefaults(suiteName: "group.\(this.hostAppBundleIdentifier)")
+ userDefaults?.set(this.toData(data: this.sharedMedia), forKey: this.sharedKey)
+ userDefaults?.synchronize()
+ this.redirectToHostApp(type: .media)
+ }
+
+ } else {
+ self?.dismissWithError()
+ }
+ }
+ }
+
+ private func handleVideos (content: NSExtensionItem, attachment: NSItemProvider, index: Int) {
+ attachment.loadItem(forTypeIdentifier: videoContentType, options:nil) { [weak self] data, error in
+
+ if error == nil, let url = data as? URL, let this = self {
+
+ // Always copy
+ let fileExtension = this.getExtension(from: url, type: .video)
+ let newName = UUID().uuidString
+ let newPath = FileManager.default
+ .containerURL(forSecurityApplicationGroupIdentifier: "group.\(this.hostAppBundleIdentifier)")!
+ .appendingPathComponent("\(newName).\(fileExtension)")
+ let copied = this.copyFile(at: url, to: newPath)
+ if(copied) {
+ guard let sharedFile = this.getSharedMediaFile(forVideo: newPath) else {
+ return
+ }
+ this.sharedMedia.append(sharedFile)
+ }
+
+ // If this is the last item, save imagesData in userDefaults and redirect to host app
+ if index == (content.attachments?.count)! - 1 {
+ let userDefaults = UserDefaults(suiteName: "group.\(this.hostAppBundleIdentifier)")
+ userDefaults?.set(this.toData(data: this.sharedMedia), forKey: this.sharedKey)
+ userDefaults?.synchronize()
+ this.redirectToHostApp(type: .media)
+ }
+
+ } else {
+ self?.dismissWithError()
+ }
+ }
+ }
+
+ private func handleFiles (content: NSExtensionItem, attachment: NSItemProvider, index: Int) {
+ attachment.loadItem(forTypeIdentifier: fileURLType, options: nil) { [weak self] data, error in
+
+ if error == nil, let url = data as? URL, let this = self {
+
+ // Always copy
+ let newName = this.getFileName(from :url)
+ let newPath = FileManager.default
+ .containerURL(forSecurityApplicationGroupIdentifier: "group.\(this.hostAppBundleIdentifier)")!
+ .appendingPathComponent("\(newName)")
+ let copied = this.copyFile(at: url, to: newPath)
+ if (copied) {
+ this.sharedMedia.append(SharedMediaFile(path: newPath.absoluteString, thumbnail: nil, duration: nil, type: .file))
+ }
+
+ if index == (content.attachments?.count)! - 1 {
+ let userDefaults = UserDefaults(suiteName: "group.\(this.hostAppBundleIdentifier)")
+ userDefaults?.set(this.toData(data: this.sharedMedia), forKey: this.sharedKey)
+ userDefaults?.synchronize()
+ this.redirectToHostApp(type: .file)
+ }
+
+ } else {
+ self?.dismissWithError()
+ }
+ }
+ }
+
+ private func dismissWithError() {
+ print("[ERROR] Error loading data!")
+ let alert = UIAlertController(title: "Error", message: "Error loading data", preferredStyle: .alert)
+
+ let action = UIAlertAction(title: "Error", style: .cancel) { _ in
+ self.dismiss(animated: true, completion: nil)
+ }
+
+ alert.addAction(action)
+ present(alert, animated: true, completion: nil)
+ extensionContext!.completeRequest(returningItems: [], completionHandler: nil)
+ }
+
+ private func redirectToHostApp(type: RedirectType) {
+ let url = URL(string: "ShareMedia://dataUrl=\(sharedKey)#\(type)")
+ var responder = self as UIResponder?
+ let selectorOpenURL = sel_registerName("openURL:")
+
+ while (responder != nil) {
+ if (responder?.responds(to: selectorOpenURL))! {
+ let _ = responder?.perform(selectorOpenURL, with: url)
+ }
+ responder = responder!.next
+ }
+ extensionContext!.completeRequest(returningItems: [], completionHandler: nil);
+ self.dismiss(animated: false, completion: nil)
+ }
+
+ enum RedirectType {
+ case media
+ case text
+ case file
+ }
+
+ func getExtension(from url: URL, type: SharedMediaType) -> String {
+ let parts = url.lastPathComponent.components(separatedBy: ".")
+ var ex: String? = nil
+ if (parts.count > 1) {
+ ex = parts.last
+ }
+
+ if (ex == nil) {
+ switch type {
+ case .image:
+ ex = "PNG"
+ case .video:
+ ex = "MP4"
+ case .file:
+ ex = "TXT"
+ }
+ }
+ return ex ?? "Unknown"
+ }
+
+ func getFileName(from url: URL) -> String {
+ var name = url.lastPathComponent
+
+ if (name == "") {
+ name = UUID().uuidString + "." + getExtension(from: url, type: .file)
+ }
+
+ return name
+ }
+
+ func copyFile(at srcURL: URL, to dstURL: URL) -> Bool {
+ do {
+ if FileManager.default.fileExists(atPath: dstURL.path) {
+ try FileManager.default.removeItem(at: dstURL)
+ }
+ try FileManager.default.copyItem(at: srcURL, to: dstURL)
+ } catch (let error) {
+ print("Cannot copy item at \(srcURL) to \(dstURL): \(error)")
+ return false
+ }
+ return true
+ }
+
+ private func getSharedMediaFile(forVideo: URL) -> SharedMediaFile? {
+ let asset = AVAsset(url: forVideo)
+ let duration = (CMTimeGetSeconds(asset.duration) * 1000).rounded()
+ let thumbnailPath = getThumbnailPath(for: forVideo)
+
+ if FileManager.default.fileExists(atPath: thumbnailPath.path) {
+ return SharedMediaFile(path: forVideo.absoluteString, thumbnail: thumbnailPath.absoluteString, duration: duration, type: .video)
+ }
+
+ var saved = false
+ let assetImgGenerate = AVAssetImageGenerator(asset: asset)
+ assetImgGenerate.appliesPreferredTrackTransform = true
+ // let scale = UIScreen.main.scale
+ assetImgGenerate.maximumSize = CGSize(width: 360, height: 360)
+ do {
+ let img = try assetImgGenerate.copyCGImage(at: CMTimeMakeWithSeconds(600, preferredTimescale: Int32(1.0)), actualTime: nil)
+ try UIImage.pngData(UIImage(cgImage: img))()?.write(to: thumbnailPath)
+ saved = true
+ } catch {
+ saved = false
+ }
+
+ return saved ? SharedMediaFile(path: forVideo.absoluteString, thumbnail: thumbnailPath.absoluteString, duration: duration, type: .video) : nil
+
+ }
+
+ private func getThumbnailPath(for url: URL) -> URL {
+ let fileName = Data(url.lastPathComponent.utf8).base64EncodedString().replacingOccurrences(of: "==", with: "")
+ let path = FileManager.default
+ .containerURL(forSecurityApplicationGroupIdentifier: "group.\(hostAppBundleIdentifier)")!
+ .appendingPathComponent("\(fileName).jpg")
+ return path
+ }
+
+ class SharedMediaFile: Codable {
+ var path: String; // can be image, video or url path. It can also be text content
+ var thumbnail: String?; // video thumbnail
+ var duration: Double?; // video duration in milliseconds
+ var type: SharedMediaType;
+
+
+ init(path: String, thumbnail: String?, duration: Double?, type: SharedMediaType) {
+ self.path = path
+ self.thumbnail = thumbnail
+ self.duration = duration
+ self.type = type
+ }
+
+ // Debug method to print out SharedMediaFile details in the console
+ func toString() {
+ print("[SharedMediaFile] \n\tpath: \(self.path)\n\tthumbnail: \(self.thumbnail)\n\tduration: \(self.duration)\n\ttype: \(self.type)")
+ }
+ }
+
+ enum SharedMediaType: Int, Codable {
+ case image
+ case video
+ case file
+ }
+
+ func toData(data: [SharedMediaFile]) -> Data {
+ let encodedData = try? JSONEncoder().encode(data)
+ return encodedData!
+ }
+}
+
+extension Array {
+ subscript (safe index: UInt) -> Element? {
+ return Int(index) < count ? self[Int(index)] : nil
+ }
+}
diff --git a/apps/mobile/ios/Notesnook.xcodeproj/project.pbxproj b/apps/mobile/ios/Notesnook.xcodeproj/project.pbxproj
index 5bcd6d053..2a0fd369c 100644
--- a/apps/mobile/ios/Notesnook.xcodeproj/project.pbxproj
+++ b/apps/mobile/ios/Notesnook.xcodeproj/project.pbxproj
@@ -19,6 +19,9 @@
6552A26B2504BD6E00D0FA37 /* DMSans-Regular.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 6552A2692504BD6E00D0FA37 /* DMSans-Regular.ttf */; };
6552A26C2504BD6E00D0FA37 /* DMSerifText-Regular.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 6552A26A2504BD6E00D0FA37 /* DMSerifText-Regular.ttf */; };
655FD77A253AD31C001D807D /* Web.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 655FD779253AD31C001D807D /* Web.bundle */; };
+ 65A7F343255687E600699170 /* ShareViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65A7F342255687E600699170 /* ShareViewController.swift */; };
+ 65A7F346255687E600699170 /* MainInterface.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 65A7F344255687E600699170 /* MainInterface.storyboard */; };
+ 65A7F34A255687E600699170 /* Add to Notes.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = 65A7F340255687E600699170 /* Add to Notes.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */; };
87CE5B71DC72F3D95B7B1AA5 /* libPods-Notesnook-tvOSTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = A03E3F5851D27269540E147C /* libPods-Notesnook-tvOSTests.a */; };
A79A93DC9D0CAE8703462151 /* libPods-Notesnook-NotesnookTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 068FA9BDFA207A50B0A9E597 /* libPods-Notesnook-NotesnookTests.a */; };
@@ -40,8 +43,29 @@
remoteGlobalIDString = 2D02E47A1E0B4A5D006451C7;
remoteInfo = "Notesnook-tvOS";
};
+ 65A7F348255687E600699170 /* PBXContainerItemProxy */ = {
+ isa = PBXContainerItemProxy;
+ containerPortal = 83CBB9F71A601CBA00E9B192 /* Project object */;
+ proxyType = 1;
+ remoteGlobalIDString = 65A7F33F255687E600699170;
+ remoteInfo = "Add to Notes";
+ };
/* End PBXContainerItemProxy section */
+/* Begin PBXCopyFilesBuildPhase section */
+ 65A7F34B255687E600699170 /* Embed App Extensions */ = {
+ isa = PBXCopyFilesBuildPhase;
+ buildActionMask = 2147483647;
+ dstPath = "";
+ dstSubfolderSpec = 13;
+ files = (
+ 65A7F34A255687E600699170 /* Add to Notes.appex in Embed App Extensions */,
+ );
+ name = "Embed App Extensions";
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXCopyFilesBuildPhase section */
+
/* Begin PBXFileReference section */
008F07F21AC5B25A0029DE68 /* main.jsbundle */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = main.jsbundle; sourceTree = "<group>"; };
00E356EE1AD99517003FC87E /* NotesnookTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = NotesnookTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -63,6 +87,12 @@
6552A2692504BD6E00D0FA37 /* DMSans-Regular.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "DMSans-Regular.ttf"; sourceTree = "<group>"; };
6552A26A2504BD6E00D0FA37 /* DMSerifText-Regular.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "DMSerifText-Regular.ttf"; sourceTree = "<group>"; };
655FD779253AD31C001D807D /* Web.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; name = Web.bundle; path = ../html/Web.bundle; sourceTree = "<group>"; };
+ 65A7F340255687E600699170 /* Add to Notes.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = "Add to Notes.appex"; sourceTree = BUILT_PRODUCTS_DIR; };
+ 65A7F342255687E600699170 /* ShareViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareViewController.swift; sourceTree = "<group>"; };
+ 65A7F345255687E600699170 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/MainInterface.storyboard; sourceTree = "<group>"; };
+ 65A7F347255687E600699170 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
+ 65A7F34F255689AD00699170 /* Notesnook.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; name = Notesnook.entitlements; path = Notesnook/Notesnook.entitlements; sourceTree = "<group>"; };
+ 65A7F35025568A3F00699170 /* Add to Notes.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "Add to Notes.entitlements"; sourceTree = "<group>"; };
747E42E32601638E75E9A3CF /* Pods-Notesnook-tvOSTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Notesnook-tvOSTests.debug.xcconfig"; path = "Target Support Files/Pods-Notesnook-tvOSTests/Pods-Notesnook-tvOSTests.debug.xcconfig"; sourceTree = "<group>"; };
77124A1C1FB538ED63FDEF82 /* Pods-Notesnook.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Notesnook.release.xcconfig"; path = "Target Support Files/Pods-Notesnook/Pods-Notesnook.release.xcconfig"; sourceTree = "<group>"; };
81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = LaunchScreen.storyboard; path = Notesnook/LaunchScreen.storyboard; sourceTree = "<group>"; };
@@ -108,6 +138,13 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
+ 65A7F33D255687E600699170 /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
@@ -131,6 +168,7 @@
13B07FAE1A68108700A75B9A /* Notesnook */ = {
isa = PBXGroup;
children = (
+ 65A7F34F255689AD00699170 /* Notesnook.entitlements */,
655FD779253AD31C001D807D /* Web.bundle */,
008F07F21AC5B25A0029DE68 /* main.jsbundle */,
13B07FAF1A68108700A75B9A /* AppDelegate.h */,
@@ -156,6 +194,17 @@
name = Frameworks;
sourceTree = "<group>";
};
+ 65A7F341255687E600699170 /* Add to Notes */ = {
+ isa = PBXGroup;
+ children = (
+ 65A7F35025568A3F00699170 /* Add to Notes.entitlements */,
+ 65A7F342255687E600699170 /* ShareViewController.swift */,
+ 65A7F344255687E600699170 /* MainInterface.storyboard */,
+ 65A7F347255687E600699170 /* Info.plist */,
+ );
+ path = "Add to Notes";
+ sourceTree = "<group>";
+ };
832341AE1AAA6A7D00B99B32 /* Libraries */ = {
isa = PBXGroup;
children = (
@@ -171,6 +220,7 @@
13B07FAE1A68108700A75B9A /* Notesnook */,
832341AE1AAA6A7D00B99B32 /* Libraries */,
00E356EF1AD99517003FC87E /* NotesnookTests */,
+ 65A7F341255687E600699170 /* Add to Notes */,
83CBBA001A601CBA00E9B192 /* Products */,
2D16E6871FA4F8E400B85C8A /* Frameworks */,
DA84645424CFBF19A44D64B3 /* Pods */,
@@ -187,6 +237,7 @@
00E356EE1AD99517003FC87E /* NotesnookTests.xctest */,
2D02E47B1E0B4A5D006451C7 /* Notesnook-tvOS.app */,
2D02E4901E0B4A5D006451C7 /* Notesnook-tvOSTests.xctest */,
+ 65A7F340255687E600699170 /* Add to Notes.appex */,
);
name = Products;
sourceTree = "<group>";
@@ -240,10 +291,12 @@
13B07F8E1A680F5B00A75B9A /* Resources */,
00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */,
240525450DF9ABA0F332B52E /* [CP] Copy Pods Resources */,
+ 65A7F34B255687E600699170 /* Embed App Extensions */,
);
buildRules = (
);
dependencies = (
+ 65A7F349255687E600699170 /* PBXTargetDependency */,
);
name = Notesnook;
productName = Notesnook;
@@ -290,12 +343,30 @@
productReference = 2D02E4901E0B4A5D006451C7 /* Notesnook-tvOSTests.xctest */;
productType = "com.apple.product-type.bundle.unit-test";
};
+ 65A7F33F255687E600699170 /* Add to Notes */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = 65A7F34E255687E600699170 /* Build configuration list for PBXNativeTarget "Add to Notes" */;
+ buildPhases = (
+ 65A7F33C255687E600699170 /* Sources */,
+ 65A7F33D255687E600699170 /* Frameworks */,
+ 65A7F33E255687E600699170 /* Resources */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ );
+ name = "Add to Notes";
+ productName = "Add to Notes";
+ productReference = 65A7F340255687E600699170 /* Add to Notes.appex */;
+ productType = "com.apple.product-type.app-extension";
+ };
/* End PBXNativeTarget section */
/* Begin PBXProject section */
83CBB9F71A601CBA00E9B192 /* Project object */ = {
isa = PBXProject;
attributes = {
+ LastSwiftUpdateCheck = 1110;
LastUpgradeCheck = 1130;
TargetAttributes = {
00E356ED1AD99517003FC87E = {
@@ -303,6 +374,7 @@
TestTargetID = 13B07F861A680F5B00A75B9A;
};
13B07F861A680F5B00A75B9A = {
+ DevelopmentTeam = 53CWBG3QUC;
LastSwiftMigration = 1120;
};
2D02E47A1E0B4A5D006451C7 = {
@@ -314,6 +386,11 @@
ProvisioningStyle = Automatic;
TestTargetID = 2D02E47A1E0B4A5D006451C7;
};
+ 65A7F33F255687E600699170 = {
+ CreatedOnToolsVersion = 11.1;
+ DevelopmentTeam = 53CWBG3QUC;
+ ProvisioningStyle = Automatic;
+ };
};
};
buildConfigurationList = 83CBB9FA1A601CBA00E9B192 /* Build configuration list for PBXProject "Notesnook" */;
@@ -333,6 +410,7 @@
00E356ED1AD99517003FC87E /* NotesnookTests */,
2D02E47A1E0B4A5D006451C7 /* Notesnook-tvOS */,
2D02E48F1E0B4A5D006451C7 /* Notesnook-tvOSTests */,
+ 65A7F33F255687E600699170 /* Add to Notes */,
);
};
/* End PBXProject section */
@@ -372,6 +450,14 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
+ 65A7F33E255687E600699170 /* Resources */ = {
+ isa = PBXResourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 65A7F346255687E600699170 /* MainInterface.storyboard in Resources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
/* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
@@ -684,6 +770,14 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
+ 65A7F33C255687E600699170 /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 65A7F343255687E600699170 /* ShareViewController.swift in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
/* End PBXSourcesBuildPhase section */
/* Begin PBXTargetDependency section */
@@ -697,8 +791,24 @@
target = 2D02E47A1E0B4A5D006451C7 /* Notesnook-tvOS */;
targetProxy = 2D02E4911E0B4A5D006451C7 /* PBXContainerItemProxy */;
};
+ 65A7F349255687E600699170 /* PBXTargetDependency */ = {
+ isa = PBXTargetDependency;
+ target = 65A7F33F255687E600699170 /* Add to Notes */;
+ targetProxy = 65A7F348255687E600699170 /* PBXContainerItemProxy */;
+ };
/* End PBXTargetDependency section */
+/* Begin PBXVariantGroup section */
+ 65A7F344255687E600699170 /* MainInterface.storyboard */ = {
+ isa = PBXVariantGroup;
+ children = (
+ 65A7F345255687E600699170 /* Base */,
+ );
+ name = MainInterface.storyboard;
+ sourceTree = "<group>";
+ };
+/* End PBXVariantGroup section */
+
/* Begin XCBuildConfiguration section */
00E356F61AD99517003FC87E /* Debug */ = {
isa = XCBuildConfiguration;
@@ -747,9 +857,12 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 19E7EB248446C3FE09F6E622 /* Pods-Notesnook.debug.xcconfig */;
buildSettings = {
+ ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
+ CODE_SIGN_ENTITLEMENTS = Notesnook/Notesnook.entitlements;
CURRENT_PROJECT_VERSION = 1;
+ DEVELOPMENT_TEAM = 53CWBG3QUC;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Notesnook/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
@@ -770,9 +883,12 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 77124A1C1FB538ED63FDEF82 /* Pods-Notesnook.release.xcconfig */;
buildSettings = {
+ ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
+ CODE_SIGN_ENTITLEMENTS = Notesnook/Notesnook.entitlements;
CURRENT_PROJECT_VERSION = 1;
+ DEVELOPMENT_TEAM = 53CWBG3QUC;
INFOPLIST_FILE = Notesnook/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
OTHER_LDFLAGS = (
@@ -897,6 +1013,62 @@
};
name = Release;
};
+ 65A7F34C255687E600699170 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ CLANG_ANALYZER_NONNULL = YES;
+ CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
+ CLANG_ENABLE_OBJC_WEAK = YES;
+ CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
+ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
+ CODE_SIGN_ENTITLEMENTS = "Add to Notes/Add to Notes.entitlements";
+ CODE_SIGN_STYLE = Automatic;
+ DEBUG_INFORMATION_FORMAT = dwarf;
+ DEVELOPMENT_TEAM = 53CWBG3QUC;
+ GCC_C_LANGUAGE_STANDARD = gnu11;
+ INFOPLIST_FILE = "Add to Notes/Info.plist";
+ IPHONEOS_DEPLOYMENT_TARGET = 13.1;
+ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
+ MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
+ MTL_FAST_MATH = YES;
+ PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.Notesnook.Add-to-Notes";
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ SKIP_INSTALL = YES;
+ SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
+ SWIFT_OPTIMIZATION_LEVEL = "-Onone";
+ SWIFT_VERSION = 5.0;
+ TARGETED_DEVICE_FAMILY = "1,2";
+ };
+ name = Debug;
+ };
+ 65A7F34D255687E600699170 /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ CLANG_ANALYZER_NONNULL = YES;
+ CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
+ CLANG_ENABLE_OBJC_WEAK = YES;
+ CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
+ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
+ CODE_SIGN_ENTITLEMENTS = "Add to Notes/Add to Notes.entitlements";
+ CODE_SIGN_STYLE = Automatic;
+ COPY_PHASE_STRIP = NO;
+ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+ GCC_C_LANGUAGE_STANDARD = gnu11;
+ INFOPLIST_FILE = "Add to Notes/Info.plist";
+ IPHONEOS_DEPLOYMENT_TARGET = 13.1;
+ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
+ MTL_FAST_MATH = YES;
+ PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.Notesnook.Add-to-Notes";
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ SKIP_INSTALL = YES;
+ SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
+ SWIFT_VERSION = 5.0;
+ TARGETED_DEVICE_FAMILY = "1,2";
+ };
+ name = Release;
+ };
83CBBA201A601CBA00E9B192 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
@@ -1049,6 +1221,15 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
+ 65A7F34E255687E600699170 /* Build configuration list for PBXNativeTarget "Add to Notes" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 65A7F34C255687E600699170 /* Debug */,
+ 65A7F34D255687E600699170 /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
83CBB9FA1A601CBA00E9B192 /* Build configuration list for PBXProject "Notesnook" */ = {
isa = XCConfigurationList;
buildConfigurations = (
diff --git a/apps/mobile/ios/Notesnook/AppDelegate.m b/apps/mobile/ios/Notesnook/AppDelegate.m
index aa0dac1e3..81d2bbbdb 100644
--- a/apps/mobile/ios/Notesnook/AppDelegate.m
+++ b/apps/mobile/ios/Notesnook/AppDelegate.m
@@ -4,6 +4,8 @@
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import "RNSplashScreen.h"
+#import <React/RCTLinkingManager.h>
+#import "ReceiveSharingIntent-Bridging-Header.h"
#ifdef FB_SONARKIT_ENABLED
#import <FlipperKit/FlipperClient.h>
@@ -49,6 +51,8 @@ static void InitializeFlipper(UIApplication *application) {
return YES;
}
+
+
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
#if DEBUG
@@ -58,4 +62,12 @@ static void InitializeFlipper(UIApplication *application) {
#endif
}
+
+- (BOOL)application:(UIApplication *)application
+ openURL:(NSURL *)url
+ options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
+{
+ return [RCTLinkingManager application:application openURL:url options:options];
+}
+
@end
diff --git a/apps/mobile/ios/Notesnook/Info.plist b/apps/mobile/ios/Notesnook/Info.plist
index c29fd6d98..7910ec9f5 100644
--- a/apps/mobile/ios/Notesnook/Info.plist
+++ b/apps/mobile/ios/Notesnook/Info.plist
@@ -24,6 +24,18 @@
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
+ <key>CFBundleURLTypes</key>
+ <array>
+ <dict>
+ <key>CFBundleTypeRole</key>
+ <string>Editor</string>
+ <key>CFBundleURLSchemes</key>
+ <array>
+ <string>ShareMedia</string>
+ </array>
+ </dict>
+ <dict/>
+ </array>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>LSSupportsOpeningDocumentsInPlace</key>
diff --git a/apps/mobile/ios/Notesnook/Notesnook.entitlements b/apps/mobile/ios/Notesnook/Notesnook.entitlements
new file mode 100644
index 000000000..f8f0c6240
--- /dev/null
+++ b/apps/mobile/ios/Notesnook/Notesnook.entitlements
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>com.apple.security.application-groups</key>
+ <array>
+ <string>group.org.reactjs.native.example.Notesnook</string>
+ </array>
+</dict>
+</plist>
diff --git a/apps/mobile/ios/Podfile.lock b/apps/mobile/ios/Podfile.lock
index 414a9a2b3..760ab5c84 100644
--- a/apps/mobile/ios/Podfile.lock
+++ b/apps/mobile/ios/Podfile.lock
@@ -255,6 +255,8 @@ PODS:
- React
- react-native-orientation (3.1.3):
- React
+ - react-native-receive-sharing-intent (1.0.4):
+ - React
- react-native-safe-area-context (3.1.4):
- React
- react-native-sodium (0.3.6):
@@ -404,6 +406,7 @@ DEPENDENCIES:
- react-native-mmkv-storage (from `../node_modules/react-native-mmkv-storage`)
- "react-native-netinfo (from `../node_modules/@react-native-community/netinfo`)"
- react-native-orientation (from `../node_modules/react-native-orientation`)
+ - react-native-receive-sharing-intent (from `../node_modules/react-native-receive-sharing-intent`)
- react-native-safe-area-context (from `../node_modules/react-native-safe-area-context`)
- react-native-sodium (from `../node_modules/react-native-sodium`)
- react-native-splash-screen (from `../node_modules/react-native-splash-screen`)
@@ -499,6 +502,8 @@ EXTERNAL SOURCES:
:path: "../node_modules/@react-native-community/netinfo"
react-native-orientation:
:path: "../node_modules/react-native-orientation"
+ react-native-receive-sharing-intent:
+ :path: "../node_modules/react-native-receive-sharing-intent"
react-native-safe-area-context:
:path: "../node_modules/react-native-safe-area-context"
react-native-sodium:
@@ -599,6 +604,7 @@ SPEC CHECKSUMS:
react-native-mmkv-storage: 023a9c501f7430319138a94889fc53691b93d73d
react-native-netinfo: 38a1e0b3e89b48e4b5833ed475d8df5f049f6f90
react-native-orientation: f1caf84d65f1a4fd4511a18f2b924e634ad7a628
+ react-native-receive-sharing-intent: feba0a332a07977549a85aa58b496eb44368366a
react-native-safe-area-context: eb91fe1fb3f7b87d9c30a7f0808407d8569d539d
react-native-sodium: c7587732667e1cdb7d0d77c2aa2e98420aad2036
react-native-splash-screen: 200d11d188e2e78cea3ad319964f6142b6384865
diff --git a/apps/mobile/src/views/Editor/EditorHeader.js b/apps/mobile/src/views/Editor/EditorHeader.js
index d4cf82baa..38d4d8866 100644
--- a/apps/mobile/src/views/Editor/EditorHeader.js
+++ b/apps/mobile/src/views/Editor/EditorHeader.js
@@ -85,11 +85,9 @@ const EditorHeader = ({noMenu}) => {
const load = async (item) => {
await loadNote(item);
- if (item.type === 'new' && item.data) {
+ if (item.type === 'new') {
textInput.current?.focus();
post('focusTitle');
-
-
Platform.OS === 'android' ? EditorWebView.current?.requestFocus() : null;
}
if (!DDS.isTab) {
diff --git a/apps/mobile/src/views/Editor/Functions.js b/apps/mobile/src/views/Editor/Functions.js
index 00d0854e8..311a61654 100644
--- a/apps/mobile/src/views/Editor/Functions.js
+++ b/apps/mobile/src/views/Editor/Functions.js
@@ -175,7 +175,7 @@ export const _onMessage = async (evt) => {
export async function clearEditor() {
clearTimer();
if (noteEdited && id) {
- await saveNote('clearEditor');
+ await saveNote();
}
if (note && note.id) {
sendNoteEditedEvent(note.id, true);