diff --git a/ios/Classes/ComWilliamrijksenOnesignalModule.h b/ios/Classes/ComWilliamrijksenOnesignalModule.h index 0dc442b..f2b6077 100644 --- a/ios/Classes/ComWilliamrijksenOnesignalModule.h +++ b/ios/Classes/ComWilliamrijksenOnesignalModule.h @@ -18,7 +18,6 @@ typedef void(^TagsResultHandler)(NSDictionary*, NSError*); - (void)deleteTag:(id)args; - (void)getTags:(id)value; - (void)setLogLevel:(id)args; -- (void)idsAvailable:(id)args; - (void)postNotification:(id)arguments; @end diff --git a/ios/Classes/ComWilliamrijksenOnesignalModule.m b/ios/Classes/ComWilliamrijksenOnesignalModule.m index 8b9e8b9..f33c3de 100644 --- a/ios/Classes/ComWilliamrijksenOnesignalModule.m +++ b/ios/Classes/ComWilliamrijksenOnesignalModule.m @@ -7,6 +7,7 @@ #import "ComWilliamrijksenOnesignalModule.h" #import "OneSignalModuleHelper.h" +#import #import "TiBase.h" #import "TiHost.h" #import "TiUtils.h" @@ -59,19 +60,17 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( }; id onesignalInitSettings = @{ - kOSSettingsKeyAutoPrompt : @NO, - kOSSettingsKeyInFocusDisplayOption : @(OSNotificationDisplayTypeNone) + kOSSettingsKeyAutoPrompt : @false }; NSString *OneSignalAppID = [[TiApp tiAppProperties] objectForKey:@"OneSignal_AppID"]; - [OneSignal setLocationShared:NO]; [OneSignal initWithLaunchOptions:launchOptions appId:OneSignalAppID handleNotificationReceived:notificationReceivedBlock handleNotificationAction:notificationOpenedBlock settings:onesignalInitSettings]; [OneSignal setLocationShared:YES]; - + OneSignal.inFocusDisplayType = OSNotificationDisplayTypeNone; return YES; } @@ -170,23 +169,6 @@ - (void)getTags:(id)args }]; } -- (void)idsAvailable:(id)args -{ - id value = args; - ENSURE_UI_THREAD(idsAvailable, value); - ENSURE_SINGLE_ARG(value, KrollCallback); - - [OneSignal IdsAvailable:^(NSString* userId, NSString* pushToken) { - NSMutableDictionary *idsDict = [NSMutableDictionary dictionaryWithDictionary:@{ - @"userId" : userId ?: @[], - @"pushToken" :pushToken ?: @[] - }]; - NSArray *invocationArray = [[NSArray alloc] initWithObjects:&idsDict count:1]; - [value call:invocationArray thisObject:self]; - [invocationArray release]; - }]; -} - - (void)postNotification:(id)arguments { id args = arguments; diff --git a/ios/com.williamrijksen.onesignal.xcodeproj/project.pbxproj b/ios/com.williamrijksen.onesignal.xcodeproj/project.pbxproj index 46b2a15..4606332 100644 --- a/ios/com.williamrijksen.onesignal.xcodeproj/project.pbxproj +++ b/ios/com.williamrijksen.onesignal.xcodeproj/project.pbxproj @@ -217,6 +217,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = 24DD6D1B1134B66800162E58 /* titanium.xcconfig */; buildSettings = { + CLANG_ENABLE_MODULES = YES; CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; DSTROOT = /tmp/ComWilliamrijksenOnesignal.dst; @@ -261,6 +262,7 @@ baseConfigurationReference = 24DD6D1B1134B66800162E58 /* titanium.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ENABLE_MODULES = YES; DSTROOT = /tmp/ComWilliamrijksenOnesignal.dst; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", diff --git a/ios/manifest b/ios/manifest index 0ddddb9..c15bf21 100644 --- a/ios/manifest +++ b/ios/manifest @@ -2,17 +2,17 @@ # this is your module manifest and used by Titanium # during compilation, packaging, distribution, etc. # -version: 2.1.1 +version: 2.2.0 apiversion: 2 architectures: armv7 arm64 i386 x86_64 description: com.williamrijksen.onesignal author: William Rijksen license: Specify your license -copyright: Copyright (c) 2018 by Enrise +copyright: Copyright (c) 2020 by Enrise # these should not be edited name: com.williamrijksen.onesignal moduleid: com.williamrijksen.onesignal guid: 67065763-fd5e-4069-a877-6c7fd328f877 platform: iphone -minsdk: 7.5.0.GA +minsdk: 8.0.0.GA diff --git a/ios/module.xcconfig b/ios/module.xcconfig index 817edeb..3c6c690 100644 --- a/ios/module.xcconfig +++ b/ios/module.xcconfig @@ -25,4 +25,4 @@ // // IMPORTANT NOTE: always use $(inherited) in your overrides // -OTHER_LDFLAGS=$(inherited) -framework UserNotifications +OTHER_LDFLAGS=$(inherited) -framework UserNotifications -framework Webkit -framework CoreGraphics diff --git a/ios/platform/OneSignal.framework/Headers b/ios/platform/OneSignal.framework/Headers new file mode 120000 index 0000000..d5ab97c --- /dev/null +++ b/ios/platform/OneSignal.framework/Headers @@ -0,0 +1 @@ +Versions/A/Headers \ No newline at end of file diff --git a/ios/platform/OneSignal.framework/Info.plist b/ios/platform/OneSignal.framework/Info.plist deleted file mode 100644 index 9fe9a28..0000000 Binary files a/ios/platform/OneSignal.framework/Info.plist and /dev/null differ diff --git a/ios/platform/OneSignal.framework/Modules b/ios/platform/OneSignal.framework/Modules new file mode 120000 index 0000000..751d64f --- /dev/null +++ b/ios/platform/OneSignal.framework/Modules @@ -0,0 +1 @@ +Versions/A/Modules \ No newline at end of file diff --git a/ios/platform/OneSignal.framework/Resources b/ios/platform/OneSignal.framework/Resources new file mode 120000 index 0000000..186f014 --- /dev/null +++ b/ios/platform/OneSignal.framework/Resources @@ -0,0 +1 @@ +Versions/A/Resources \ No newline at end of file diff --git a/ios/platform/OneSignal.framework/Headers/OneSignal.h b/ios/platform/OneSignal.framework/Versions/A/Headers/OneSignal.h similarity index 78% rename from ios/platform/OneSignal.framework/Headers/OneSignal.h rename to ios/platform/OneSignal.framework/Versions/A/Headers/OneSignal.h index 4272344..6dc5c8c 100755 --- a/ios/platform/OneSignal.framework/Headers/OneSignal.h +++ b/ios/platform/OneSignal.framework/Versions/A/Headers/OneSignal.h @@ -1,32 +1,31 @@ /** - * Modified MIT License - * - * Copyright 2017 OneSignal - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * 1. The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * 2. All copies of substantial portions of the Software may only be used in connection - * with services provided by OneSignal. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. + Modified MIT License + + Copyright 2017 OneSignal + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + 1. The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + 2. All copies of substantial portions of the Software may only be used in connection + with services provided by OneSignal. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. */ -/*** - +/** ### Setting up the SDK ### Follow the documentation from https://documentation.onesignal.com/docs/ios-sdk-setupto setup OneSignal in your app. @@ -40,16 +39,10 @@ ### More ### iOS Push Cert: https://documentation.onesignal.com/docs/generating-an-ios-push-certificate - -***/ +*/ #import - -#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 100000 -#define XC8_AVAILABLE 1 #import -#endif - #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wstrict-prototypes" @@ -73,7 +66,6 @@ typedef NS_ENUM(NSUInteger, OSNotificationDisplayType) { OSNotificationDisplayTypeNotification }; - @interface OSNotificationAction : NSObject /* The type of the notification action */ @@ -84,9 +76,7 @@ typedef NS_ENUM(NSUInteger, OSNotificationDisplayType) { @end - -// #### Notification Payload Received Object - +/* Notification Payload Received Object */ @interface OSNotificationPayload : NSObject /* Unique Message Identifier */ @@ -133,7 +123,7 @@ typedef NS_ENUM(NSUInteger, OSNotificationDisplayType) { @property(readonly)NSString* subtitle; @property(readonly)NSString* body; -/* Web address to launch within the app via a UIWebView */ +/* Web address to launch within the app via a WKWebView */ @property(readonly)NSString* launchURL; /* Additional key value properties set within the payload */ @@ -152,9 +142,14 @@ typedef NS_ENUM(NSUInteger, OSNotificationDisplayType) { /* iOS 10+ : Groups notifications into threads */ @property(readonly)NSString *threadId; +/* Parses an APS push payload into a OSNotificationPayload object. + Useful to call from your NotificationServiceExtension when the + didReceiveNotificationRequest:withContentHandler: method fires. */ ++ (instancetype)parseWithApns:(nonnull NSDictionary*)message; + @end -// ## OneSignal OSNotification +/* OneSignal OSNotification */ @interface OSNotification : NSObject /* Notification Payload */ @@ -176,18 +171,14 @@ typedef NS_ENUM(NSUInteger, OSNotificationDisplayType) { @property(readonly, getter=isSilentNotification)BOOL silentNotification; /* iOS 10+: Indicates whether or not the received notification has mutableContent : 1 assigned to its payload - Used for UNNotificationServiceExtension to launch extension. -*/ -#if XC8_AVAILABLE + Used for UNNotificationServiceExtension to launch extension. */ @property(readonly, getter=hasMutableContent)BOOL mutableContent; -#endif /* Convert object into an NSString that can be convertible into a custom Dictionary / JSON Object */ - (NSString*)stringify; @end - @interface OSNotificationOpenedResult : NSObject @property(readonly)OSNotification* notification; @@ -198,6 +189,57 @@ typedef NS_ENUM(NSUInteger, OSNotificationDisplayType) { @end; +@interface OSInAppMessageAction : NSObject + +/* The action name attached to the IAM action */ +@property (strong, nonatomic, nullable) NSString *clickName; + +/* The URL (if any) that should be opened when the action occurs */ +@property (strong, nonatomic, nullable) NSURL *clickUrl; + +/* Whether or not the click action is first click on the IAM */ +@property (nonatomic) BOOL firstClick; + +/* Whether or not the click action dismisses the message */ +@property (nonatomic) BOOL closesMessage; + +@end + +@protocol OSInAppMessageDelegate +@optional +- (void)handleMessageAction:(OSInAppMessageAction * _Nonnull)action NS_SWIFT_NAME(handleMessageAction(action:)); +@end + +/* OneSignal Session Types */ +typedef NS_ENUM(NSUInteger, Session) { + DIRECT, + INDIRECT, + UNATTRIBUTED, + DISABLED +}; + +@interface OSOutcomeEvent : NSObject + +// Session enum (DIRECT, INDIRECT, UNATTRIBUTED, or DISABLED) to determine code route and request params +@property (nonatomic) Session session; + +// Notification ids for the current session +@property (strong, nonatomic, nullable) NSArray *notificationIds; + +// Id or name of the event +@property (strong, nonatomic, nonnull) NSString *name; + +// Time of the event occurring +@property (strong, nonatomic, nonnull) NSNumber *timestamp; + +// A weight to attach to the outcome name +@property (strong, nonatomic, nonnull) NSDecimalNumber *weight; + +// Convert the object into a NSDictionary +- (NSDictionary * _Nonnull)jsonRepresentation; + +@end + typedef NS_ENUM(NSInteger, OSNotificationPermission) { // The user has not yet made a choice regarding whether your app can show notifications. @@ -213,8 +255,6 @@ typedef NS_ENUM(NSInteger, OSNotificationPermission) { OSNotificationPermissionProvisional }; - - // Permission Classes @interface OSPermissionState : NSObject @@ -293,6 +333,7 @@ typedef NS_ENUM(NSInteger, OSNotificationPermission) { typedef void (^OSWebOpenURLResultBlock)(BOOL shouldOpen); +/*Block for generic results on success and errors on failure*/ typedef void (^OSResultSuccessBlock)(NSDictionary* result); typedef void (^OSFailureBlock)(NSError* error); @@ -305,6 +346,13 @@ typedef void (^OSHandleNotificationReceivedBlock)(OSNotification* notification); /*Block for handling a user reaction to a notification*/ typedef void (^OSHandleNotificationActionBlock)(OSNotificationOpenedResult * result); +/*Block for handling user click on an in app message*/ +typedef void (^OSHandleInAppMessageActionClickBlock)(OSInAppMessageAction* action); + +/*Block for handling outcome event being sent successfully*/ +typedef void (^OSSendOutcomeSuccess)(OSOutcomeEvent* outcome); + + /*Dictionary of keys to pass alongside the init settings*/ /*Let OneSignal directly prompt for push notifications on init*/ @@ -332,8 +380,6 @@ extern NSString * const kOSSettingsKeyInFocusDisplayOption; */ extern NSString * const kOSSettingsKeyProvidesAppNotificationSettings; - - // ======= OneSignal Class Interface ========= @interface OneSignal : NSObject @@ -344,10 +390,10 @@ typedef NS_ENUM(NSUInteger, ONE_S_LOG_LEVEL) { }; -/** +/* Initialize OneSignal. Sends push token to OneSignal so you can later send notifications. -*/ + */ // - Initialization + (id)initWithLaunchOptions:(NSDictionary*)launchOptions appId:(NSString*)appId; @@ -378,7 +424,7 @@ typedef NS_ENUM(NSUInteger, ONE_S_LOG_LEVEL) { // - Logging + (void)setLogLevel:(ONE_S_LOG_LEVEL)logLevel visualLevel:(ONE_S_LOG_LEVEL)visualLogLevel; -+ (void) onesignal_Log:(ONE_S_LOG_LEVEL)logLevel message:(NSString*)message; ++ (void)onesignal_Log:(ONE_S_LOG_LEVEL)logLevel message:(NSString*)message; // - Tagging + (void)sendTag:(NSString*)key value:(NSString*)value onSuccess:(OSResultSuccessBlock)successBlock onFailure:(OSFailureBlock)failureBlock; @@ -412,6 +458,8 @@ typedef NS_ENUM(NSUInteger, ONE_S_LOG_LEVEL) { + (void)removeEmailSubscriptionObserver:(NSObject*)observer; + (void)setSubscription:(BOOL)enable; ++ (BOOL)isInAppMessagingPaused; ++ (void)pauseInAppMessages:(BOOL)pause; // - Posting Notification + (void)postNotification:(NSDictionary*)jsonData; @@ -422,11 +470,13 @@ typedef NS_ENUM(NSUInteger, ONE_S_LOG_LEVEL) { // - Request and track user's location + (void)promptLocation; + (void)setLocationShared:(BOOL)enable; ++ (BOOL)isLocationShared; // Only used for wrapping SDKs, such as Unity, Cordova, Xamarin, etc. + (void)setMSDKType:(NSString*)type; ++ (void)setInAppMessageClickHandler:(OSHandleInAppMessageActionClickBlock)delegate; // iOS 10 only // Process from Notification Service Extension. @@ -444,22 +494,37 @@ typedef void (^OSEmailSuccessBlock)(); // Email Auth Token is a (recommended) optional parameter that should *NOT* be generated on the client. // For security purposes, the emailAuthToken should be generated by your backend server. // If you do not have a backend server for your application, use the version of thge setEmail: method without an emailAuthToken parameter. ++ (void)setEmail:(NSString * _Nonnull)email withEmailAuthHashToken:(NSString * _Nullable)hashToken; + (void)setEmail:(NSString * _Nonnull)email withEmailAuthHashToken:(NSString * _Nullable)hashToken withSuccess:(OSEmailSuccessBlock _Nullable)successBlock withFailure:(OSEmailFailureBlock _Nullable)failureBlock; // Sets email without an authentication token ++ (void)setEmail:(NSString * _Nonnull)email; + (void)setEmail:(NSString * _Nonnull)email withSuccess:(OSEmailSuccessBlock _Nullable)successBlock withFailure:(OSEmailFailureBlock _Nullable)failureBlock; // Logs the device out of the current email. ++ (void)logoutEmail; + (void)logoutEmailWithSuccess:(OSEmailSuccessBlock _Nullable)successBlock withFailure:(OSEmailFailureBlock _Nullable)failureBlock; -//convenience - no completion blocks -+ (void)logoutEmail; -+ (void)setEmail:(NSString * _Nonnull)email; -+ (void)setEmail:(NSString * _Nonnull)email withEmailAuthHashToken:(NSString * _Nullable)hashToken; +// External user id + (void)setExternalUserId:(NSString * _Nonnull)externalId; + (void)removeExternalUserId; +// In-App Messaging triggers ++ (void)addTrigger:(NSString * _Nonnull)key withValue:(id _Nonnull)value; ++ (void)addTriggers:(NSDictionary * _Nonnull)triggers; ++ (void)removeTriggerForKey:(NSString * _Nonnull)key; ++ (void)removeTriggersForKeys:(NSArray * _Nonnull)keys; ++ (NSDictionary * _Nonnull)getTriggers; ++ (id _Nullable)getTriggerValueForKey:(NSString * _Nonnull)key; + +// Outcome Events ++ (void)sendOutcome:(NSString * _Nonnull)name; ++ (void)sendOutcome:(NSString * _Nonnull)name onSuccess:(OSSendOutcomeSuccess _Nullable)success; ++ (void)sendUniqueOutcome:(NSString * _Nonnull)name; ++ (void)sendUniqueOutcome:(NSString * _Nonnull)name onSuccess:(OSSendOutcomeSuccess _Nullable)success; ++ (void)sendOutcomeWithValue:(NSString * _Nonnull)name value:(NSNumber * _Nonnull)value; ++ (void)sendOutcomeWithValue:(NSString * _Nonnull)name value:(NSNumber * _Nonnull)value onSuccess:(OSSendOutcomeSuccess _Nullable)success; @end #pragma clang diagnostic pop diff --git a/ios/platform/OneSignal.framework/Modules/module.modulemap b/ios/platform/OneSignal.framework/Versions/A/Modules/module.modulemap old mode 100644 new mode 100755 similarity index 100% rename from ios/platform/OneSignal.framework/Modules/module.modulemap rename to ios/platform/OneSignal.framework/Versions/A/Modules/module.modulemap diff --git a/ios/platform/OneSignal.framework/Versions/A/OneSignal b/ios/platform/OneSignal.framework/Versions/A/OneSignal new file mode 100755 index 0000000..6a55bb8 Binary files /dev/null and b/ios/platform/OneSignal.framework/Versions/A/OneSignal differ diff --git a/ios/platform/OneSignal.framework/Versions/A/Resources/Info.plist b/ios/platform/OneSignal.framework/Versions/A/Resources/Info.plist new file mode 100755 index 0000000..3f4182e Binary files /dev/null and b/ios/platform/OneSignal.framework/Versions/A/Resources/Info.plist differ diff --git a/ios/platform/OneSignal.framework/Versions/Current b/ios/platform/OneSignal.framework/Versions/Current new file mode 120000 index 0000000..8c7e5a6 --- /dev/null +++ b/ios/platform/OneSignal.framework/Versions/Current @@ -0,0 +1 @@ +A \ No newline at end of file diff --git a/ios/titanium.xcconfig b/ios/titanium.xcconfig index f043dfd..1092319 100644 --- a/ios/titanium.xcconfig +++ b/ios/titanium.xcconfig @@ -4,8 +4,7 @@ // OF YOUR TITANIUM SDK YOU'RE BUILDING FOR // // -TITANIUM_SDK_VERSION = 7.5.0.GA - +TITANIUM_SDK_VERSION = 8.3.1.GA // // THESE SHOULD BE OK GENERALLY AS-IS @@ -13,5 +12,5 @@ TITANIUM_SDK_VERSION = 7.5.0.GA TITANIUM_SDK = ~/Library/Application Support/Titanium/mobilesdk/osx/$(TITANIUM_SDK_VERSION) TITANIUM_BASE_SDK = "$(TITANIUM_SDK)/iphone/include" TITANIUM_BASE_SDK2 = "$(TITANIUM_SDK)/iphone/include/TiCore" -TITANIUM_BASE_SDK3 = "$(TITANIUM_SDK)/iphone/include/JavaScriptCore" +FRAMEWORK_SEARCH_PATHS = $(inherited) "$(TITANIUM_SDK)/iphone/Frameworks" HEADER_SEARCH_PATHS= $(TITANIUM_BASE_SDK) $(TITANIUM_BASE_SDK2) $(TITANIUM_BASE_SDK3)