Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit cde180e

Browse files
[[ iOS 8 Support ]] Updated push notification registration to use new iOS 8 APIs.
[[ iOS 8 Support ]] Updated reviphone to handle the launching of the iOS 8 simulator. [[ iOS 8 Support ]] Updated the deploy command to handle iOS 8 sim builds.
1 parent c4961e3 commit cde180e

File tree

8 files changed

+826
-178
lines changed

8 files changed

+826
-178
lines changed

engine/src/deploy_macosx.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,9 @@ struct load_command {
342342
#define LC_DYLD_INFO_ONLY 0x80000022
343343
#define LC_SOURCE_VERSION 0x2A
344344

345+
// MM-2014-09-30: [[ iOS 8 Support ]] Used by iOS 8 simulator builds.
346+
#define LC_MAIN (0x28|LC_REQ_DYLD) /* replacement for LC_UNIXTHREAD */
347+
345348
/*
346349
* A variable length string in a load command is represented by an lc_str
347350
* union. The strings are stored just after the load command structure and
@@ -886,6 +889,7 @@ static void swap_load_command(bool p_to_network, uint32_t p_type, load_command*
886889
case LC_THREAD:
887890
case LC_UNIXTHREAD:
888891
case LC_LOAD_DYLINKER:
892+
case LC_MAIN:
889893
swap_load_command_hdr(p_to_network, *x);
890894
break;
891895

@@ -1263,6 +1267,7 @@ static bool MCDeployToMacOSXMain(const MCDeployParameters& p_params, bool p_big_
12631267
case LC_VERSION_MIN_MACOSX:
12641268
case LC_VERSION_MIN_IPHONEOS:
12651269
case LC_SOURCE_VERSION:
1270+
case LC_MAIN:
12661271
break;
12671272

12681273
// Any others that are present are an error since we don't know

engine/src/mbliphoneapp.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,11 @@ enum MCIPhoneApplicationStatus
140140

141141
//////////
142142

143+
// MM-2014-09-30: [[ iOS 8 Support ]] Method called after successully registering (push) notification settings.
144+
#ifdef __IPHONE_8_0
145+
- (void)application: (UIApplication *)application didRegisterUserNotificationSettings: (UIUserNotificationSettings *)notificationSettings;
146+
#endif
147+
143148
//- (void)applicationDidFinishLaunching:(UIApplication *)application;
144149
- (BOOL)application:(UIApplication *)p_application didFinishLaunchingWithOptions:(NSDictionary *)p_launchOptions;
145150
- (void)application:(UIApplication *)p_application didReceiveLocalNotification:(UILocalNotification *)p_notification;

engine/src/mbliphoneapp.mm

Lines changed: 61 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -275,34 +275,61 @@ - (BOOL)application:(UIApplication *)p_application didFinishLaunchingWithOptions
275275
// Get the info dictionary.
276276
NSDictionary *t_info_dict;
277277
t_info_dict = [[NSBundle mainBundle] infoDictionary];
278-
279-
// Read the allowed notification types from the plist.
280-
NSArray *t_allowed_push_notifications_array;
281-
t_allowed_push_notifications_array = [t_info_dict objectForKey: @"CFSupportedRemoteNotificationTypes"];
282-
UIRemoteNotificationType t_allowed_notifications = UIRemoteNotificationTypeNone;
283-
if (t_allowed_push_notifications_array != nil)
284-
{
285-
for (NSString *t_push_notification_string in t_allowed_push_notifications_array)
286-
{
287-
if ([t_push_notification_string isEqualToString: @"CFBadge"])
288-
t_allowed_notifications = (UIRemoteNotificationType) (t_allowed_notifications | UIRemoteNotificationTypeBadge);
289-
else if ([t_push_notification_string isEqualToString: @"CFSound"])
290-
t_allowed_notifications = (UIRemoteNotificationType) (t_allowed_notifications | UIRemoteNotificationTypeSound);
291-
else if ([t_push_notification_string isEqualToString: @"CFAlert"])
292-
t_allowed_notifications = (UIRemoteNotificationType) (t_allowed_notifications | UIRemoteNotificationTypeAlert);
293-
}
294-
}
295278

296-
// IM-2012-02-13 don't try to register if there are no allowed push notification types
297-
if (t_allowed_notifications != UIRemoteNotificationTypeNone)
279+
// Read the allowed notification types from the plist.
280+
NSArray *t_allowed_push_notifications_array;
281+
t_allowed_push_notifications_array = [t_info_dict objectForKey: @"CFSupportedRemoteNotificationTypes"];
282+
283+
if (t_allowed_push_notifications_array != nil)
298284
{
299-
// Inform the device what kind of push notifications we can handle.
300-
301-
// MW-2013-07-29: [[ Bug 10979 ]] Dynamically call the 'registerForRemoteNotificationTypes' to
302-
// avoid app-store warnings.
303-
objc_msgSend([UIApplication sharedApplication], sel_getUid("registerForRemoteNotificationTypes:"), t_allowed_notifications);
285+
// MM-2014-09-30: [[ iOS 8 Support ]] Use new iOS 8 registration methods for push notifications.
286+
if (![[UIApplication sharedApplication] respondsToSelector :@selector(registerUserNotificationSettings:)])
287+
{
288+
UIRemoteNotificationType t_allowed_notifications = UIRemoteNotificationTypeNone;
289+
for (NSString *t_push_notification_string in t_allowed_push_notifications_array)
290+
{
291+
if ([t_push_notification_string isEqualToString: @"CFBadge"])
292+
t_allowed_notifications = (UIRemoteNotificationType) (t_allowed_notifications | UIRemoteNotificationTypeBadge);
293+
else if ([t_push_notification_string isEqualToString: @"CFSound"])
294+
t_allowed_notifications = (UIRemoteNotificationType) (t_allowed_notifications | UIRemoteNotificationTypeSound);
295+
else if ([t_push_notification_string isEqualToString: @"CFAlert"])
296+
t_allowed_notifications = (UIRemoteNotificationType) (t_allowed_notifications | UIRemoteNotificationTypeAlert);
297+
}
298+
299+
// IM-2012-02-13 don't try to register if there are no allowed push notification types
300+
if (t_allowed_notifications != UIRemoteNotificationTypeNone)
301+
{
302+
// Inform the device what kind of push notifications we can handle.
303+
304+
// MW-2013-07-29: [[ Bug 10979 ]] Dynamically call the 'registerForRemoteNotificationTypes' to
305+
// avoid app-store warnings.
306+
objc_msgSend([UIApplication sharedApplication], sel_getUid("registerForRemoteNotificationTypes:"), t_allowed_notifications);
307+
}
308+
}
309+
#ifdef __IPHONE_8_0
310+
else
311+
{
312+
UIUserNotificationType t_allowed_notifications;
313+
t_allowed_notifications = UIUserNotificationTypeNone;
314+
for (NSString *t_push_notification_string in t_allowed_push_notifications_array)
315+
{
316+
if ([t_push_notification_string isEqualToString: @"CFBadge"])
317+
t_allowed_notifications = (UIRemoteNotificationType) (t_allowed_notifications | UIUserNotificationTypeBadge);
318+
else if ([t_push_notification_string isEqualToString: @"CFSound"])
319+
t_allowed_notifications = (UIRemoteNotificationType) (t_allowed_notifications | UIUserNotificationTypeSound);
320+
else if ([t_push_notification_string isEqualToString: @"CFAlert"])
321+
t_allowed_notifications = (UIRemoteNotificationType) (t_allowed_notifications | UIUserNotificationTypeAlert);
322+
}
323+
if (t_allowed_notifications != UIUserNotificationTypeNone)
324+
{
325+
UIUserNotificationSettings *t_push_settings;
326+
t_push_settings = [UIUserNotificationSettings settingsForTypes: t_allowed_notifications categories:nil];
327+
[[UIApplication sharedApplication] registerUserNotificationSettings: t_push_settings];
328+
}
329+
}
330+
#endif
304331
}
305-
332+
306333
// MM-2014-09-26: [[ iOS 8 Support ]] Move the registration for orientation updates to here from init. Was causing issues with iOS 8.
307334
// Tell the device we want orientation notifications.
308335
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
@@ -314,6 +341,15 @@ - (BOOL)application:(UIApplication *)p_application didFinishLaunchingWithOptions
314341
object: nil];
315342
}
316343

344+
// MM-2014-09-30: [[ iOS 8 Support ]] Method called after successully registering (push) notification settings.
345+
// Call registerForRemoteNotifications to finish off push notification registration process. (Will send didRegisterForRemoteNotificationsWithDeviceToken which will be handled as before.)
346+
#ifdef __IPHONE_8_0
347+
- (void)application: (UIApplication *)p_application didRegisterUserNotificationSettings: (UIUserNotificationSettings *)p_notificationSettings
348+
{
349+
[p_application registerForRemoteNotifications];
350+
}
351+
#endif
352+
317353
- (void)application:(UIApplication *)p_application didReceiveLocalNotification:(UILocalNotification *)p_notification
318354
{
319355
MCLog("application:didReceiveLocalNotification:");

revmobile/reviphone.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454

5555
/* Begin PBXFileReference section */
5656
3CE9FF2A113D4DA9002F594F /* iPhoneSimulatorRemoteClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = iPhoneSimulatorRemoteClient.h; path = src/iPhoneSimulatorRemoteClient.h; sourceTree = "<group>"; };
57+
4C30FE2B19D99B3B00DAFF52 /* CoreSimulator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CoreSimulator.h; path = src/CoreSimulator.h; sourceTree = "<group>"; };
5758
4CAA4CEA18D3400400EFEC4B /* DVTiPhoneSimulatorRemoteClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DVTiPhoneSimulatorRemoteClient.h; path = src/DVTiPhoneSimulatorRemoteClient.h; sourceTree = "<group>"; };
5859
4D8C22191212A2F800DA8A58 /* reviphoneproxy.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = reviphoneproxy.mm; path = src/reviphoneproxy.mm; sourceTree = "<group>"; };
5960
4D8C22211212A72200DA8A58 /* reviphoneproxy */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = reviphoneproxy; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -122,6 +123,7 @@
122123
4D8F6A78113D13F80056ED41 /* Source */ = {
123124
isa = PBXGroup;
124125
children = (
126+
4C30FE2B19D99B3B00DAFF52 /* CoreSimulator.h */,
125127
4CAA4CEA18D3400400EFEC4B /* DVTiPhoneSimulatorRemoteClient.h */,
126128
3CE9FF2A113D4DA9002F594F /* iPhoneSimulatorRemoteClient.h */,
127129
4D8F6A80113D141F0056ED41 /* reviphone.mm */,
@@ -198,8 +200,6 @@
198200
/* Begin PBXProject section */
199201
4D8F6A0C113D13140056ED41 /* Project object */ = {
200202
isa = PBXProject;
201-
attributes = {
202-
};
203203
buildConfigurationList = 4D8F6A0F113D13140056ED41 /* Build configuration list for PBXProject "reviphone" */;
204204
compatibilityVersion = "Xcode 3.2";
205205
developmentRegion = English;

0 commit comments

Comments
 (0)