Skip to content

Commit

Permalink
iOS fixes for launch args
Browse files Browse the repository at this point in the history
  • Loading branch information
scottrules44 committed Mar 7, 2022
1 parent 19b35ea commit 56260c2
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 8 deletions.
Binary file modified plugins/2020.3569/iphone-sim/libNotificationsV2Plugin.a
Binary file not shown.
Binary file modified plugins/2020.3569/iphone/libNotificationsV2Plugin.a
Binary file not shown.
43 changes: 41 additions & 2 deletions src/ios/Plugin/CoronaNotificationsDelegate.mm
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,48 @@
#if PLUGIN_FIREBASE
#import <FirebaseMessaging/FirebaseMessaging.h>
#endif

static int
SetLaunchArgs( UIApplication *application, NSDictionary *launchOptions, lua_State *L )
{
int itemsPushed = 0;
UILocalNotification *localNotification = [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey];
if ( localNotification )
{
IPhoneLocalNotificationEvent e(
localNotification, IPhoneNotificationEvent::ToApplicationState( application.applicationState ) );
e.Push( L );
itemsPushed = 1;
}

NSDictionary *remoteNotification =
[launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];

if ( remoteNotification )
{
IPhoneRemoteNotificationEvent e(
remoteNotification, IPhoneNotificationEvent::ToApplicationState( application.applicationState ) );
e.Push( L );
itemsPushed = 1;
}

return itemsPushed;
}
@implementation CoronaNotificationsDelegate

- (int)execute:(id<CoronaRuntime>)runtime command:(NSString*)command param:(id)param
{
lua_State *L = runtime.L;
int itemsPushed = 0;
if ( [command isEqualToString:@"pushLaunchArgKey"] )
{
lua_pushstring( L, "notification" );
itemsPushed = 1;
}
else if ( [command isEqualToString:@"pushLaunchArgValue" ] )
{
itemsPushed = SetLaunchArgs( [UIApplication sharedApplication], param, L);
}
return itemsPushed;
}
- (void)willLoadMain:(id<CoronaRuntime>)runtime
{
// NOP
Expand Down
3 changes: 2 additions & 1 deletion src/ios/Plugin/NotificationsV2Plugin.mm
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,8 @@ static bool isFirebaseLinked() {

UILocalNotification *notification = IPhoneLocalNotificationEvent::CreateAndSchedule( L, 1 );
int allowedNotificationTypes = UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert;
id settings = [UIUserNotificationSettings settingsForTypes:allowedNotificationTypes categories:nil];
Class cls = NSClassFromString(@"UIUserNotificationSettings");
id settings = [cls settingsForTypes:allowedNotificationTypes categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:settings];
[[UIApplication sharedApplication] scheduleLocalNotification:notification];

Expand Down
7 changes: 2 additions & 5 deletions src/ios/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ echo "OUTPUT_DIR: $OUTPUT_DIR"
checkError

# iOS
xcodebuild -project "$path/Plugin.xcodeproj" -configuration $CONFIG -sdk iphoneos -alltargets
xcodebuild -project "$path/Plugin.xcodeproj" -configuration $CONFIG -sdk iphoneos -alltargets -UseModernBuildSystem=NO
checkError

# iOS-sim
xcodebuild -project "$path/Plugin.xcodeproj" -configuration $CONFIG -sdk iphonesimulator -alltargets
xcodebuild -project "$path/Plugin.xcodeproj" -configuration $CONFIG -sdk iphonesimulator -alltargets -UseModernBuildSystem=NO
checkError

# create universal binary
Expand Down Expand Up @@ -126,6 +126,3 @@ TARGET_NAME=NotificationsV2Plugin
build_plugin_structure "$OUTPUT_DIR/BuiltPlugin/Regular/iphone" iphoneos " -extract armv7 -extract arm64 " EmbeddedFrameworks-none

build_plugin_structure "$OUTPUT_DIR/BuiltPlugin/Regular/iphone-sim" iphonesimulator " -extract i386 -extract x86_64 " EmbeddedFrameworksSim-none



0 comments on commit 56260c2

Please sign in to comment.