Skip to content

Commit

Permalink
- print logs update version ShoutSocial#3.
Browse files Browse the repository at this point in the history
  • Loading branch information
saadabouelsooud committed Sep 8, 2022
1 parent df4718a commit 80ba75c
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
2 changes: 1 addition & 1 deletion share_handler/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: share_handler
description: A Flutter plugin to handle incoming shared text/media, as well as add share to suggestions/shortcuts.
repository: https://github.com/AboutShout/share_handler/tree/main/share_handler
publish_to: none
version: 0.0.17
version: 0.0.18

environment:
sdk: ">=2.14.0 <3.0.0"
Expand Down
20 changes: 19 additions & 1 deletion share_handler_ios/ios/Classes/SwiftShareHandlerIosPlatform.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public class SwiftShareHandlerIosPlatform: NSObject, FlutterPlugin, FlutterStrea
public func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [AnyHashable : Any] = [:]) -> Bool {
if let url = launchOptions[UIApplication.LaunchOptionsKey.url] as? URL {
if (hasMatchingSchemePrefix(url: url)) {
print("inside package application didFinishLaunchingWithOptions if (hasMatchingSchemePrefix(url: url)) url: \(url)")
return handleUrl(url: url, setInitialData: true)
}
return true
Expand All @@ -100,6 +101,7 @@ public class SwiftShareHandlerIosPlatform: NSObject, FlutterPlugin, FlutterStrea
// Reference: https://developer.apple.com/documentation/uikit/uiapplicationdelegate/1623112-application
public func application(_ application: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
if (hasMatchingSchemePrefix(url: url)) {
print("inside package application open url if (hasMatchingSchemePrefix(url: url)) url: \(url)")
return handleUrl(url: url, setInitialData: false)
}
return false
Expand All @@ -114,6 +116,8 @@ public class SwiftShareHandlerIosPlatform: NSObject, FlutterPlugin, FlutterStrea
public func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([Any]) -> Void) -> Bool {
if let url = userActivity.webpageURL {
if (hasMatchingSchemePrefix(url: url)) {
print("inside package application continue userActivity if (hasMatchingSchemePrefix(url: url)) url: \(url)")

return handleUrl(url: url, setInitialData: true)
}
}
Expand All @@ -125,16 +129,22 @@ public class SwiftShareHandlerIosPlatform: NSObject, FlutterPlugin, FlutterStrea
// let appDomain = Bundle.main.bundleIdentifier!
let appGroupId = (Bundle.main.object(forInfoDictionaryKey: "AppGroupId") as? String) ?? "group.\(Bundle.main.bundleIdentifier!)"
let userDefaults = UserDefaults(suiteName: appGroupId)


print("inside package handleUrl appGroupId: \(appGroupId) & userDefaults:\(userDefaults)")

var sharedMedia: SharedMedia?

let params = url.queryDictionary
if let sharedPreferencesKey = params?["key"] {
if let data = userDefaults?.object(forKey: sharedPreferencesKey) as? Data {
sharedMedia = try? JSONDecoder().decode(SharedMedia.self, from: data)
print("inside package handleUrl if sharedPreferencesKey = params?['key'] sharedMedia: \(sharedMedia) & data:\(data)")

}
} else if url.absoluteString.hasPrefix("file://") {
sharedMedia = SharedMedia.init(attachments: [SharedAttachment.init(path: url.absoluteString, type: SharedAttachmentType.file)], conversationIdentifier: nil, content: nil, speakableGroupName: nil, serviceName: nil, senderIdentifier: nil, imageFilePath: nil)
print("inside package handleUrl if url.absoluteString.hasPrefix sharedMedia: \(sharedMedia) & url.absoluteString:\(url.absoluteString)")

}

if let media = sharedMedia {
Expand All @@ -144,6 +154,8 @@ public class SwiftShareHandlerIosPlatform: NSObject, FlutterPlugin, FlutterStrea
initialMedia = media
}
let map = media.toDictionary()
print("inside package before eventSink map: \(map) ")

eventSink?(map)

return true
Expand Down Expand Up @@ -216,13 +228,19 @@ public class SwiftShareHandlerIosPlatform: NSObject, FlutterPlugin, FlutterStrea

private func getAbsolutePath(for identifier: String) -> String? {
if (identifier.starts(with: "file://") || identifier.starts(with: "/var/mobile/Media") || identifier.starts(with: "/private/var/mobile")) {
print("inside package getAbsolutePath identifier: \(identifier)")

return identifier.replacingOccurrences(of: "file://", with: "")
}
let phAsset = PHAsset.fetchAssets(withLocalIdentifiers: [identifier], options: .none).firstObject
if(phAsset == nil) {
print("inside package if(phAsset == nil) ")

return nil
}
let (url, _) = getFullSizeImageURLAndOrientation(for: phAsset!)
print("inside package getAbsolutePath url: \(url)")

return url
}

Expand Down
2 changes: 1 addition & 1 deletion share_handler_ios/ios/share_handler_ios.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
Pod::Spec.new do |s|
s.name = 'share_handler_ios'
s.version = '0.0.10'
s.version = '0.0.11'
s.summary = 'iOS implementation of the share_handler plugin.'
s.description = <<-DESC
iOS implementation of the share_handler plugin.
Expand Down
2 changes: 1 addition & 1 deletion share_handler_ios/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: share_handler_ios
description: An implementation for the iOS platform of the Flutter share_handler plugin.
repository: https://github.com/AboutShout/share_handler/tree/main/share_handler_ios
publish_to: none
version: 0.0.10
version: 0.0.11

environment:
sdk: ">=2.14.0 <3.0.0"
Expand Down

0 comments on commit 80ba75c

Please sign in to comment.