Skip to content

Commit

Permalink
Merge pull request #803 from mixpanel/fix-warnings
Browse files Browse the repository at this point in the history
Fix warnings for iOS 10, Xcode 10 support
  • Loading branch information
zihejia authored Oct 15, 2018
2 parents f9e78d8 + 4f102a5 commit caa6445
Show file tree
Hide file tree
Showing 16 changed files with 203 additions and 321 deletions.
11 changes: 6 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
language: objective-c
before_install:
- gem install cocoapods -v 1.3.1
osx_image: xcode9.3
- gem uninstall cocoapods --force -a -q -I -x
- gem install cocoapods -v 1.4.0
osx_image: xcode10
branches:
only:
- master
Expand All @@ -10,8 +11,8 @@ env:
- WORKSPACE="HelloMixpanel/HelloMixpanel.xcworkspace"
- SCHEME="[iOS] HelloMixpanel"
matrix:
- DESTINATION="OS=10.0,name=iPhone 7" RUN_TESTS="YES" POD_LINT="YES"
- DESTINATION="OS=11.1,name=iPhone X" RUN_TESTS="YES" POD_LINT="NO"
- DESTINATION="OS=10.0,name=iPhone 5s" RUN_TESTS="YES" POD_LINT="YES"
- DESTINATION="OS=12.0,name=iPhone X" RUN_TESTS="YES" POD_LINT="YES"
podfile: HelloMixpanel/podfile
script:
- set -o pipefail
Expand All @@ -25,5 +26,5 @@ script:
# Run `pod lib lint` if specified
# allow warnings while surveys are deprecated but not yet removed. disallow them again later
- if [ $POD_LINT == "YES" ]; then
pod lib lint --allow-warnings;
pod lib lint --allow-warnings --no-clean;
fi
44 changes: 30 additions & 14 deletions HelloMixpanel/HelloMixpanel.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1068,9 +1068,14 @@
files = (
);
inputPaths = (
"${SRCROOT}/Pods/Target Support Files/Pods-HelloMixpanelTests/Pods-HelloMixpanelTests-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/Nocilla-iOS/Nocilla.framework",
"${BUILT_PRODUCTS_DIR}/OCMock-iOS/OCMock.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Nocilla.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/OCMock.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
Expand All @@ -1083,13 +1088,16 @@
files = (
);
inputPaths = (
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
"${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-HelloMixpanel_tvOSTests-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
6EDEBFE516C45FD65271D88E /* [CP] Copy Pods Resources */ = {
Expand All @@ -1113,9 +1121,14 @@
files = (
);
inputPaths = (
"${SRCROOT}/Pods/Target Support Files/Pods-HelloMixpanel_tvOSTests/Pods-HelloMixpanel_tvOSTests-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/Nocilla-tvOS/Nocilla.framework",
"${BUILT_PRODUCTS_DIR}/OCMock-tvOS/OCMock.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Nocilla.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/OCMock.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
Expand Down Expand Up @@ -1143,13 +1156,16 @@
files = (
);
inputPaths = (
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
"${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-HelloMixpanelTests-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */
Expand Down Expand Up @@ -1513,7 +1529,7 @@
GCC_WARN_STRICT_SELECTOR_MATCH = YES;
GCC_WARN_UNDECLARED_SELECTOR = NO;
INFOPLIST_FILE = "HelloMixpanel/HelloMixpanel-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
OTHER_CFLAGS = (
"$(inherited)",
Expand Down Expand Up @@ -1551,7 +1567,7 @@
GCC_WARN_STRICT_SELECTOR_MATCH = YES;
GCC_WARN_UNDECLARED_SELECTOR = NO;
INFOPLIST_FILE = "HelloMixpanel/HelloMixpanel-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
OTHER_CFLAGS = (
"$(inherited)",
Expand Down Expand Up @@ -1598,7 +1614,7 @@
"\"$(SRCROOT)/../Mixpanel\"/**",
);
INFOPLIST_FILE = "HelloMixpanelTests/HelloMixpanelTests-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @loader_path/Frameworks";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
Expand Down Expand Up @@ -1640,7 +1656,7 @@
"\"$(SRCROOT)/../Mixpanel\"/**",
);
INFOPLIST_FILE = "HelloMixpanelTests/HelloMixpanelTests-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @loader_path/Frameworks";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
Expand Down Expand Up @@ -1747,7 +1763,7 @@
GCC_WARN_STRICT_SELECTOR_MATCH = YES;
GCC_WARN_UNDECLARED_SELECTOR = NO;
INFOPLIST_FILE = "HelloMixpanel/HelloMixpanel-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
OTHER_CFLAGS = (
"$(inherited)",
Expand Down Expand Up @@ -1789,7 +1805,7 @@
"\"$(SRCROOT)/../Mixpanel\"/**",
);
INFOPLIST_FILE = "HelloMixpanelTests/HelloMixpanelTests-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @loader_path/Frameworks";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
Expand Down Expand Up @@ -1836,7 +1852,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = appletvos;
TARGETED_DEVICE_FAMILY = 3;
TVOS_DEPLOYMENT_TARGET = 9.0;
TVOS_DEPLOYMENT_TARGET = 10.0;
};
name = Debug;
};
Expand Down Expand Up @@ -1870,7 +1886,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = appletvos;
TARGETED_DEVICE_FAMILY = 3;
TVOS_DEPLOYMENT_TARGET = 9.0;
TVOS_DEPLOYMENT_TARGET = 10.0;
VALIDATE_PRODUCT = YES;
};
name = Release;
Expand Down Expand Up @@ -1904,7 +1920,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = appletvos;
TARGETED_DEVICE_FAMILY = 3;
TVOS_DEPLOYMENT_TARGET = 9.0;
TVOS_DEPLOYMENT_TARGET = 10.0;
VALIDATE_PRODUCT = YES;
};
name = AppStore;
Expand Down Expand Up @@ -1946,7 +1962,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = appletvos;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/HelloMixpanel_tvOS.app/HelloMixpanel_tvOS";
TVOS_DEPLOYMENT_TARGET = 9.2;
TVOS_DEPLOYMENT_TARGET = 10.0;
TV_OS_TEST = 1;
};
name = Debug;
Expand Down Expand Up @@ -1985,7 +2001,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = appletvos;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/HelloMixpanel_tvOS.app/HelloMixpanel_tvOS";
TVOS_DEPLOYMENT_TARGET = 9.2;
TVOS_DEPLOYMENT_TARGET = 10.0;
TV_OS_TEST = 1;
VALIDATE_PRODUCT = YES;
};
Expand Down Expand Up @@ -2024,7 +2040,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = appletvos;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/HelloMixpanel_tvOS.app/HelloMixpanel_tvOS";
TVOS_DEPLOYMENT_TARGET = 9.2;
TVOS_DEPLOYMENT_TARGET = 10.0;
TV_OS_TEST = 1;
VALIDATE_PRODUCT = YES;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
codeCoverageEnabled = "YES">
codeCoverageEnabled = "YES"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
Expand Down Expand Up @@ -104,7 +104,7 @@
<EnvironmentVariable
key = "OS_ACTIVITY_MODE"
value = "disable"
isEnabled = "YES">
isEnabled = "NO">
</EnvironmentVariable>
</EnvironmentVariables>
<AdditionalOptions>
Expand Down
42 changes: 15 additions & 27 deletions HelloMixpanel/HelloMixpanel/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(

self.mixpanel.checkForNotificationsOnActive = YES;
self.mixpanel.showNotificationOnActive = YES; //Change this to NO to show your notifs manually.

self.mixpanel.enableLogging = YES;

// Set the upload interval to 20 seconds for demonstration purposes. This would be overkill for most applications.
self.mixpanel.flushInterval = 20; // defaults to 60 seconds

Expand All @@ -50,30 +51,29 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
});
}
}];
} else {
UIUserNotificationSettings *userNotificationSettings = [UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert) categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:userNotificationSettings];
[[UIApplication sharedApplication] registerForRemoteNotifications];
}

return YES;
}

#pragma mark - Push notifications

- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
{
[[UIApplication sharedApplication] registerForRemoteNotifications];
}

- (void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forRemoteNotification:(NSDictionary *)userInfo completionHandler:(void (^)(void))completionHandler
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
didReceiveNotificationResponse:(UNNotificationResponse *)response
withCompletionHandler:(void (^)(void))completionHandler
{
if ([identifier isEqualToString:@"declineAction"]) {
if ([response.actionIdentifier isEqualToString:@"declineAction"]) {
NSLog(@"%@ user declined push notification action", self);

} else if ([identifier isEqualToString:@"answerAction"]) {
} else if ([response.actionIdentifier isEqualToString:@"answerAction"]) {
NSLog(@"%@ user answered push notification action", self);
}

UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"" message:response.notification.request.content.userInfo[@"aps"][@"alert"] preferredStyle:UIAlertControllerStyleAlert];
[alert addAction:[UIAlertAction actionWithTitle:@"Okay" style:UIAlertActionStyleDefault handler:nil]];
[self.window.rootViewController presentViewController:alert animated:YES completion:nil];

completionHandler();
}

- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)devToken {
Expand All @@ -88,22 +88,10 @@ - (void)application:(UIApplication *)app didFailToRegisterForRemoteNotifications
#endif
}

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
// Show alert for push notifications recevied while the app is running
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"" message:userInfo[@"aps"][@"alert"] preferredStyle:UIAlertControllerStyleAlert];
[alert addAction:[UIAlertAction actionWithTitle:@"Okay" style:UIAlertActionStyleDefault handler:nil]];
[self.window.rootViewController presentViewController:alert animated:YES completion:nil];
}

-(void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler{
- (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler{
completionHandler(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge);
}

-(void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void(^)())completionHandler{
completionHandler();
}


#pragma mark - Session timing example

Expand Down
Loading

0 comments on commit caa6445

Please # to comment.