Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ios): support macOS target (Catalyst) #11279

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 2 additions & 6 deletions iphone/Classes/AnalyticsModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*/

#import "AnalyticsModule.h"
@import TitaniumKit.APSAnalytics;
@import TitaniumKit.TiBase;
@import TitaniumKit.TiUtils;

Expand Down Expand Up @@ -38,7 +37,7 @@ - (NSString *)apiName

- (NSString *)lastEvent
{
return [[APSAnalytics sharedInstance] performSelector:@selector(getLastEvent)];
return @"";
}

- (void)navEvent:(NSString *)from to:(NSString *)to withName:(NSString *)name withData:(NSDictionary *)data
Expand All @@ -58,7 +57,6 @@ - (void)navEvent:(NSString *)from to:(NSString *)to withName:(NSString *)name wi
if (data == nil) {
data = [NSDictionary dictionary];
}
[[APSAnalytics sharedInstance] sendAppNavEventFromView:from toView:to withName:name payload:data];
}

- (NSInteger)featureEvent:(NSString *)name withData:(id)data
Expand Down Expand Up @@ -87,7 +85,6 @@ - (NSInteger)featureEvent:(NSString *)name withData:(id)data
data = value;
}
if ([AnalyticsModule validatePayload:data level:0]) {
[[APSAnalytics sharedInstance] sendAppFeatureEvent:name payload:data];
return JSON_VALIDATION_PASSED;
}

Expand All @@ -113,12 +110,11 @@ - (void)filterEvents:(NSArray *)events

- (void)setOptedOut:(BOOL)optedOut
{
[[APSAnalytics sharedInstance] setOptedOut:optedOut];
}

- (BOOL)optedOut
{
return [[APSAnalytics sharedInstance] isOptedOut];
return NO;
}

READWRITE_IMPL(BOOL, optedOut, OptedOut);
Expand Down
2 changes: 2 additions & 0 deletions iphone/Classes/ContactsModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/
#import <TitaniumKit/TiModule.h>

#if !TARGET_OS_MACCATALYST
#ifdef USE_TI_CONTACTS

#import "TiContactsPerson.h"
Expand Down Expand Up @@ -58,3 +59,4 @@
@end

#endif
#endif
3 changes: 3 additions & 0 deletions iphone/Classes/ContactsModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*/

#if !TARGET_OS_MACCATALYST
#ifdef USE_TI_CONTACTS

#import "ContactsModule.h"
Expand Down Expand Up @@ -664,3 +666,4 @@ - (void)didUpdatePerson:(TiContactsPerson *)person
@end

#endif
#endif
19 changes: 3 additions & 16 deletions iphone/Classes/GeolocationModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

extern NSString *const TI_APPLICATION_GUID;

@interface GeolocationCallback : NSObject <APSHTTPRequestDelegate> {
@interface GeolocationCallback : NSObject {
JSValue *callback;
}
- (id)initWithCallback:(JSValue *)callback;
Expand Down Expand Up @@ -52,19 +52,6 @@ - (void)start:(NSDictionary *)params
NSString *value = [TiUtils stringValue:[params objectForKey:key]];
[url appendFormat:@"%@=%@&", key, [value stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLHostAllowedCharacterSet]]];
}

APSHTTPRequest *req = [[APSHTTPRequest alloc] init];
[req addRequestHeader:@"User-Agent" value:[[TiApp app] systemUserAgent]];
[req setUrl:[NSURL URLWithString:url]];
[req setDelegate:self];
[req setMethod:@"GET"];
// Place it in the main thread since we're not using a queue and yet we need the
// delegate methods to be called...
TiThreadPerformOnMainThread(^{
[req send];
[req autorelease];
},
NO);
}

- (void)requestSuccess:(NSString *)data
Expand All @@ -77,7 +64,7 @@ - (void)requestError:(NSError *)error
[callback callWithArguments:@[ event ]];
}

- (void)request:(APSHTTPRequest *)request onLoad:(APSHTTPResponse *)response
- (void)request:(id)request onLoad:(id)response
{
[[TiApp app] stopNetwork];

Expand All @@ -91,7 +78,7 @@ - (void)request:(APSHTTPRequest *)request onLoad:(APSHTTPResponse *)response
[self autorelease];
}

- (void)request:(APSHTTPRequest *)request onError:(APSHTTPResponse *)response
- (void)request:(id)request onError:(id)response
{
[[TiApp app] stopNetwork];
[self requestError:[response error]];
Expand Down
24 changes: 2 additions & 22 deletions iphone/Classes/MediaModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@
#import <QuartzCore/QuartzCore.h>
#import <UIKit/UIPopoverController.h>
#ifdef USE_TI_MEDIAHASPHOTOGALLERYPERMISSIONS
#if !TARGET_OS_MACCATALYST
#import <AssetsLibrary/AssetsLibrary.h>
#endif
#endif
#import "TiUIiOSLivePhoto.h"
#ifdef USE_TI_MEDIAVIDEOPLAYER
#import "TiMediaVideoPlayerProxy.h"
Expand Down Expand Up @@ -417,28 +419,6 @@ - (NSNumber *)defaultAudioSessionMode

- (void)setAudioSessionMode:(NSNumber *)mode
{
DEPRECATED_REPLACED(@"Media.audioSessionMode", @"7.0.0", @"Media.audioSessionCategory");

switch ([mode unsignedIntegerValue]) {
case kAudioSessionCategory_AmbientSound:
[self setAudioSessionCategory:[self AUDIO_SESSION_CATEGORY_AMBIENT]];
break;
case kAudioSessionCategory_SoloAmbientSound:
[self setAudioSessionCategory:[self AUDIO_SESSION_CATEGORY_SOLO_AMBIENT]];
break;
case kAudioSessionCategory_PlayAndRecord:
[self setAudioSessionCategory:[self AUDIO_SESSION_CATEGORY_PLAY_AND_RECORD]];
break;
case kAudioSessionCategory_RecordAudio:
[self setAudioSessionCategory:[self AUDIO_SESSION_CATEGORY_RECORD]];
break;
case kAudioSessionCategory_MediaPlayback:
[self setAudioSessionCategory:[self AUDIO_SESSION_CATEGORY_PLAYBACK]];
break;
default:
DebugLog(@"Unsupported audioSessionMode specified");
break;
}
}

- (void)setAudioSessionCategory:(NSString *)mode
Expand Down
3 changes: 0 additions & 3 deletions iphone/Classes/TiAppiOSProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -736,9 +736,6 @@ - (TiAppiOSLocalNotificationProxy *)scheduleLocalNotification:(id)args
CLRegion *circularRegion = [[CLCircularRegion alloc] initWithCenter:CLLocationCoordinate2DMake(latitude, longitude)
radius:radius
identifier:identifier];

trigger = [UNLocationNotificationTrigger triggerWithRegion:circularRegion
repeats:triggersOnce];
RELEASE_TO_NIL(circularRegion);
} else {
DebugLog(@"[ERROR] Notifications in iOS 10 require the either a `date` or `region` property to be set.");
Expand Down
10 changes: 0 additions & 10 deletions iphone/Classes/TiAppiOSUserNotificationCenterProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -232,16 +232,6 @@ - (NSDictionary *)dictionaryWithUserNotificationRequest:(UNNotificationRequest *

if ([[request trigger] isKindOfClass:[UNCalendarNotificationTrigger class]]) {
[event setObject:NULL_IF_NIL([(UNCalendarNotificationTrigger *)[request trigger] nextTriggerDate]) forKey:@"date"];
} else if ([[request trigger] isKindOfClass:[UNLocationNotificationTrigger class]]) {
CLCircularRegion *region = (CLCircularRegion *)[(UNLocationNotificationTrigger *)[request trigger] region];

NSDictionary *dict = @{
@"latitude" : NUMDOUBLE(region.center.latitude),
@"longitude" : NUMDOUBLE(region.center.longitude),
@"radius" : NUMDOUBLE(region.radius),
@"identifier" : region.identifier
};
[event setObject:dict forKey:@"region"];
}

return event;
Expand Down
3 changes: 3 additions & 0 deletions iphone/Classes/TiContactsGroup.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
*/
#import <TitaniumKit/TiProxy.h>

#if !TARGET_OS_MACCATALYST

#ifdef USE_TI_CONTACTS
#import "ContactsModule.h"
#import <AddressBook/AddressBook.h>
Expand All @@ -23,3 +25,4 @@

@end
#endif
#endif
2 changes: 2 additions & 0 deletions iphone/Classes/TiContactsGroup.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*/
#if !TARGET_OS_MACCATALYST
#ifdef USE_TI_CONTACTS
#import "TiContactsGroup.h"

Expand Down Expand Up @@ -240,3 +241,4 @@ - (CNSaveRequest *)getSaveRequestForAddition:(NSString *)containerIdentifier
#endif
@end
#endif
#endif
2 changes: 2 additions & 0 deletions iphone/Classes/TiContactsPerson.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/
#import <TitaniumKit/TiProxy.h>

#if !TARGET_OS_MACCATALYST
#ifdef USE_TI_CONTACTS

#import <AddressBook/AddressBook.h>
Expand Down Expand Up @@ -52,3 +53,4 @@
@end

#endif
#endif
2 changes: 2 additions & 0 deletions iphone/Classes/TiContactsPerson.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*/
#if !TARGET_OS_MACCATALYST
#ifdef USE_TI_CONTACTS

#import "TiContactsPerson.h"
Expand Down Expand Up @@ -635,3 +636,4 @@ - (void)checkAndNotifyObserver

@end
#endif
#endif
13 changes: 7 additions & 6 deletions iphone/Classes/TiNetworkHTTPClientProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,25 @@
* Please see the LICENSE included with this distribution for details.
*/

#if !TARGET_OS_MACCATALYST
#ifdef USE_TI_NETWORK

#import "TiDOMDocumentProxy.h"
#import <TitaniumKit/APSHTTPClient.h>
#import <TitaniumKit/TiProxy.h>

@class TiBlob;

@protocol SecurityManagerProtocol <NSObject>
@required
- (BOOL)willHandleURL:(NSURL *)url;
- (id<APSConnectionDelegate>)connectionDelegateForUrl:(NSURL *)url;
- (id)connectionDelegateForUrl:(NSURL *)url;
@end

@interface TiNetworkHTTPClientProxy : TiProxy <APSHTTPRequestDelegate> {
APSHTTPRequest *httpRequest;
@interface TiNetworkHTTPClientProxy : TiProxy {
id httpRequest;
NSTimeInterval _uploadTime;
NSTimeInterval _downloadTime;
id<APSConnectionDelegate> apsConnectionDelegate;
id apsConnectionDelegate;
id<SecurityManagerProtocol> apsConnectionManager;

BOOL hasOnload;
Expand All @@ -34,7 +34,7 @@
BOOL hasOnredirect;
}

@property (nonatomic, readonly) APSHTTPResponse *response;
@property (nonatomic, readonly) id response;

// state information
@property (nonatomic, readonly) NSNumber *status;
Expand Down Expand Up @@ -76,3 +76,4 @@
@end

#endif
#endif