From b68e74d4548aa4339d07a5e29891a2f33a8dc9b3 Mon Sep 17 00:00:00 2001 From: mx1700 Date: Sat, 6 Jul 2019 16:41:50 +0800 Subject: [PATCH] =?UTF-8?q?iOS=20=E6=8E=A8=E9=80=81=E6=88=90=E5=8A=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- android/app/build.gradle | 1 + .../java/com/timepill/MainApplication.java | 1 + android/settings.gradle | 2 + ios/Timepill.xcodeproj/project.pbxproj | 75 +++++++++++ .../xcshareddata/xcschemes/Timepill.xcscheme | 2 +- ios/Timepill/AppDelegate.m | 119 ++++++++++++++++++ package-lock.json | 46 +++++-- package.json | 1 + 8 files changed, 235 insertions(+), 12 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index cd91b28..b518d8a 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -142,6 +142,7 @@ android { dependencies { + implementation project(':react-native-smart-xgpush') implementation project(':rn-fetch-blob') implementation project(':react-native-image-crop-picker') implementation project(':react-native-image-resizer') diff --git a/android/app/src/main/java/com/timepill/MainApplication.java b/android/app/src/main/java/com/timepill/MainApplication.java index 78fbdfa..03fbb92 100644 --- a/android/app/src/main/java/com/timepill/MainApplication.java +++ b/android/app/src/main/java/com/timepill/MainApplication.java @@ -3,6 +3,7 @@ package com.timepill; import android.app.Application; import com.facebook.react.ReactApplication; +import com.rain.day.XGPushPackage; import com.RNFetchBlob.RNFetchBlobPackage; import com.reactnative.ivpusic.imagepicker.PickerPackage; import fr.bamlab.rnimageresizer.ImageResizerPackage; diff --git a/android/settings.gradle b/android/settings.gradle index 4ec7cf7..790c556 100644 --- a/android/settings.gradle +++ b/android/settings.gradle @@ -1,4 +1,6 @@ rootProject.name = 'Timepill' +include ':react-native-smart-xgpush' +project(':react-native-smart-xgpush').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-smart-xgpush/android') include ':rn-fetch-blob' project(':rn-fetch-blob').projectDir = new File(rootProject.projectDir, '../node_modules/rn-fetch-blob/android') include ':react-native-image-crop-picker' diff --git a/ios/Timepill.xcodeproj/project.pbxproj b/ios/Timepill.xcodeproj/project.pbxproj index 21f5a66..affb72b 100644 --- a/ios/Timepill.xcodeproj/project.pbxproj +++ b/ios/Timepill.xcodeproj/project.pbxproj @@ -47,9 +47,15 @@ 444B74B0B45F447FA6D25561 /* libRNVectorIcons.a in Frameworks */ = {isa = PBXBuildFile; fileRef = A333F2A12D224289B26028D1 /* libRNVectorIcons.a */; }; 47AE5EA4A39F43CFA279144B /* libRNDeviceInfo.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4B6943EF54DC4C0E8C860C48 /* libRNDeviceInfo.a */; }; 505DDEF9B17C4B93A7D4C4B0 /* libRCTImageResizer.a in Frameworks */ = {isa = PBXBuildFile; fileRef = C988095E6478452AAAF73E23 /* libRCTImageResizer.a */; }; + 693ABBB722D093C20044FDF8 /* CoreTelephony.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 693ABBB622D093C20044FDF8 /* CoreTelephony.framework */; }; + 693ABBB922D093CE0044FDF8 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 693ABBB822D093CE0044FDF8 /* SystemConfiguration.framework */; }; + 693ABBBB22D093DE0044FDF8 /* UserNotifications.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 693ABBBA22D093DD0044FDF8 /* UserNotifications.framework */; }; + 693ABBBD22D093EC0044FDF8 /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 693ABBBC22D093EC0044FDF8 /* libz.tbd */; }; + 693ABBBF22D093FA0044FDF8 /* libsqlite3.0.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 693ABBBE22D093FA0044FDF8 /* libsqlite3.0.tbd */; }; 6CA03C7B6F034CF5B2ECC3E5 /* libRNVectorIcons-tvOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7FC4807EA1FA42A4A55BDAE5 /* libRNVectorIcons-tvOS.a */; }; 6CAEBF678D2F4D3A8D88B88A /* EvilIcons.ttf in Resources */ = {isa = PBXBuildFile; fileRef = CC35BDC2C50846E0A4F98D35 /* EvilIcons.ttf */; }; 71E72460768C4C9EB73C5050 /* MaterialCommunityIcons.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 0D4DF9EF3F764CD0BF997FD6 /* MaterialCommunityIcons.ttf */; }; + 7497C6D0D64344B197447DC7 /* libRCTXGPushModule.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 62865F98E711415DBA4DAFF9 /* libRCTXGPushModule.a */; }; 7CDD27C257FA4106B76D549E /* FontAwesome.ttf in Resources */ = {isa = PBXBuildFile; fileRef = C558ABC6E5C94D939958E5F9 /* FontAwesome.ttf */; }; 832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 832341B51AAA6A8300B99B32 /* libRCTText.a */; }; 9678DE108DEC4C5A9D92EA1D /* libimageCropPicker.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 996469B8096342559A8F98D6 /* libimageCropPicker.a */; }; @@ -382,6 +388,13 @@ remoteGlobalIDString = 2D2A28201D9B03D100D4039D; remoteInfo = "RCTAnimation-tvOS"; }; + 693ABBB422D0939A0044FDF8 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 461950EE4FD949249DD2937B /* RCTXGPushModule.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = B779C03A206113DE0039BF59; + remoteInfo = RCTXGPushModule; + }; 78C398B81ACF4ADC00677621 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */; @@ -452,9 +465,17 @@ 4156314A2297CFA5009EB583 /* RSKImageCropper.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = RSKImageCropper.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 4156314E2297CFBE009EB583 /* QBImagePicker.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = QBImagePicker.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 4166A0DE22895B4B0086277D /* ReactNativeNavigation.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = ReactNativeNavigation.xcodeproj; path = "../node_modules/react-native-navigation/lib/ios/ReactNativeNavigation.xcodeproj"; sourceTree = ""; }; + 461950EE4FD949249DD2937B /* RCTXGPushModule.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = RCTXGPushModule.xcodeproj; path = "../node_modules/react-native-smart-xgpush/ios/RCTXGPushModule.xcodeproj"; sourceTree = ""; }; 4B6943EF54DC4C0E8C860C48 /* libRNDeviceInfo.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRNDeviceInfo.a; sourceTree = ""; }; 4DC49BDD3EFD4FA997BEEF58 /* Zocial.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = Zocial.ttf; path = "../node_modules/react-native-vector-icons/Fonts/Zocial.ttf"; sourceTree = ""; }; 5E91572D1DD0AC6500FF2AA8 /* RCTAnimation.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTAnimation.xcodeproj; path = "../node_modules/react-native/Libraries/NativeAnimation/RCTAnimation.xcodeproj"; sourceTree = ""; }; + 62865F98E711415DBA4DAFF9 /* libRCTXGPushModule.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRCTXGPushModule.a; sourceTree = ""; }; + 693ABB6B22D0925E0044FDF8 /* Timepill.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; name = Timepill.entitlements; path = Timepill/Timepill.entitlements; sourceTree = ""; }; + 693ABBB622D093C20044FDF8 /* CoreTelephony.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreTelephony.framework; path = System/Library/Frameworks/CoreTelephony.framework; sourceTree = SDKROOT; }; + 693ABBB822D093CE0044FDF8 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; }; + 693ABBBA22D093DD0044FDF8 /* UserNotifications.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UserNotifications.framework; path = System/Library/Frameworks/UserNotifications.framework; sourceTree = SDKROOT; }; + 693ABBBC22D093EC0044FDF8 /* libz.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libz.tbd; path = usr/lib/libz.tbd; sourceTree = SDKROOT; }; + 693ABBBE22D093FA0044FDF8 /* libsqlite3.0.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libsqlite3.0.tbd; path = usr/lib/libsqlite3.0.tbd; sourceTree = SDKROOT; }; 6D8788EB66CB42AAAE311EF6 /* Feather.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = Feather.ttf; path = "../node_modules/react-native-vector-icons/Fonts/Feather.ttf"; sourceTree = ""; }; 784C7C58E2B04EECBD71EF5E /* libRNDeviceInfo-tvOS.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = "libRNDeviceInfo-tvOS.a"; sourceTree = ""; }; 78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTLinking.xcodeproj; path = "../node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj"; sourceTree = ""; }; @@ -492,6 +513,11 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 693ABBBF22D093FA0044FDF8 /* libsqlite3.0.tbd in Frameworks */, + 693ABBBD22D093EC0044FDF8 /* libz.tbd in Frameworks */, + 693ABBBB22D093DE0044FDF8 /* UserNotifications.framework in Frameworks */, + 693ABBB922D093CE0044FDF8 /* SystemConfiguration.framework in Frameworks */, + 693ABBB722D093C20044FDF8 /* CoreTelephony.framework in Frameworks */, 4166A0E722895B5C0086277D /* libReactNativeNavigation.a in Frameworks */, ED297163215061F000B7C4FE /* JavaScriptCore.framework in Frameworks */, ADBDB9381DFEBF1600ED6528 /* libRCTBlob.a in Frameworks */, @@ -514,6 +540,7 @@ 9678DE108DEC4C5A9D92EA1D /* libimageCropPicker.a in Frameworks */, 4156314F2297CFBE009EB583 /* QBImagePicker.framework in Frameworks */, 35DCFF50947D4FCBBF5A8921 /* libRNFetchBlob.a in Frameworks */, + 7497C6D0D64344B197447DC7 /* libRCTXGPushModule.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -628,6 +655,7 @@ 13B07FAE1A68108700A75B9A /* Timepill */ = { isa = PBXGroup; children = ( + 693ABB6B22D0925E0044FDF8 /* Timepill.entitlements */, 008F07F21AC5B25A0029DE68 /* main.jsbundle */, 13B07FAF1A68108700A75B9A /* AppDelegate.h */, 13B07FB01A68108700A75B9A /* AppDelegate.m */, @@ -665,6 +693,11 @@ 2D16E6871FA4F8E400B85C8A /* Frameworks */ = { isa = PBXGroup; children = ( + 693ABBBE22D093FA0044FDF8 /* libsqlite3.0.tbd */, + 693ABBBC22D093EC0044FDF8 /* libz.tbd */, + 693ABBBA22D093DD0044FDF8 /* UserNotifications.framework */, + 693ABBB822D093CE0044FDF8 /* SystemConfiguration.framework */, + 693ABBB622D093C20044FDF8 /* CoreTelephony.framework */, ED297162215061F000B7C4FE /* JavaScriptCore.framework */, ED2971642150620600B7C4FE /* JavaScriptCore.framework */, 2D16E6891FA4F8E400B85C8A /* libReact.a */, @@ -716,6 +749,7 @@ C988095E6478452AAAF73E23 /* libRCTImageResizer.a */, 996469B8096342559A8F98D6 /* libimageCropPicker.a */, B2E8AA4B1D85497E86DAA92C /* libRNFetchBlob.a */, + 62865F98E711415DBA4DAFF9 /* libRCTXGPushModule.a */, ); name = "Recovered References"; sourceTree = ""; @@ -754,6 +788,14 @@ name = Products; sourceTree = ""; }; + 693ABBB122D0939A0044FDF8 /* Products */ = { + isa = PBXGroup; + children = ( + 693ABBB522D0939A0044FDF8 /* libRCTXGPushModule.a */, + ); + name = Products; + sourceTree = ""; + }; 78C398B11ACF4ADC00677621 /* Products */ = { isa = PBXGroup; children = ( @@ -785,6 +827,7 @@ DE970E03BCC84CE8A281A103 /* RCTImageResizer.xcodeproj */, BDBA91D5680B4ACA83A7844B /* imageCropPicker.xcodeproj */, 99151F1A82BD48E0B5416458 /* RNFetchBlob.xcodeproj */, + 461950EE4FD949249DD2937B /* RCTXGPushModule.xcodeproj */, ); name = Libraries; sourceTree = ""; @@ -946,6 +989,11 @@ }; 13B07F861A680F5B00A75B9A = { DevelopmentTeam = 96T8KJDKQ3; + SystemCapabilities = { + com.apple.Push = { + enabled = 1; + }; + }; }; 2D02E47A1E0B4A5D006451C7 = { CreatedOnToolsVersion = 8.2.1; @@ -1023,6 +1071,10 @@ ProductGroup = 139FDEE71B06529A00C62182 /* Products */; ProjectRef = 139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */; }, + { + ProductGroup = 693ABBB122D0939A0044FDF8 /* Products */; + ProjectRef = 461950EE4FD949249DD2937B /* RCTXGPushModule.xcodeproj */; + }, { ProductGroup = 146834001AC3E56700842450 /* Products */; ProjectRef = 146833FF1AC3E56700842450 /* React.xcodeproj */; @@ -1360,6 +1412,13 @@ remoteRef = 5E9157341DD0AC6500FF2AA8 /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; + 693ABBB522D0939A0044FDF8 /* libRCTXGPushModule.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = libRCTXGPushModule.a; + remoteRef = 693ABBB422D0939A0044FDF8 /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; 78C398B91ACF4ADC00677621 /* libRCTLinking.a */ = { isa = PBXReferenceProxy; fileType = archive.ar; @@ -1539,6 +1598,7 @@ "$(SRCROOT)/../node_modules/react-native-image-resizer/ios/RCTImageResizer", "$(SRCROOT)/../node_modules/react-native-image-crop-picker/ios/**", "$(SRCROOT)/../node_modules/rn-fetch-blob/ios/**", + "$(SRCROOT)/../node_modules/react-native-smart-xgpush/ios/RCTXGPushModule", ); INFOPLIST_FILE = TimepillTests/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 9.0; @@ -1553,6 +1613,7 @@ "\"$(SRCROOT)/$(TARGET_NAME)\"", "\"$(SRCROOT)/$(TARGET_NAME)\"", "\"$(SRCROOT)/$(TARGET_NAME)\"", + "\"$(SRCROOT)/$(TARGET_NAME)\"", ); OTHER_LDFLAGS = ( "-ObjC", @@ -1578,6 +1639,7 @@ "$(SRCROOT)/../node_modules/react-native-image-resizer/ios/RCTImageResizer", "$(SRCROOT)/../node_modules/react-native-image-crop-picker/ios/**", "$(SRCROOT)/../node_modules/rn-fetch-blob/ios/**", + "$(SRCROOT)/../node_modules/react-native-smart-xgpush/ios/RCTXGPushModule", ); INFOPLIST_FILE = TimepillTests/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 9.0; @@ -1592,6 +1654,7 @@ "\"$(SRCROOT)/$(TARGET_NAME)\"", "\"$(SRCROOT)/$(TARGET_NAME)\"", "\"$(SRCROOT)/$(TARGET_NAME)\"", + "\"$(SRCROOT)/$(TARGET_NAME)\"", ); OTHER_LDFLAGS = ( "-ObjC", @@ -1607,6 +1670,7 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_ENTITLEMENTS = Timepill/Timepill.entitlements; CURRENT_PROJECT_VERSION = 1; DEAD_CODE_STRIPPING = NO; DEVELOPMENT_TEAM = 96T8KJDKQ3; @@ -1618,6 +1682,7 @@ "$(SRCROOT)/../node_modules/react-native-image-resizer/ios/RCTImageResizer", "$(SRCROOT)/../node_modules/react-native-image-crop-picker/ios/**", "$(SRCROOT)/../node_modules/rn-fetch-blob/ios/**", + "$(SRCROOT)/../node_modules/react-native-smart-xgpush/ios/RCTXGPushModule", ); INFOPLIST_FILE = Timepill/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; @@ -1636,6 +1701,7 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_ENTITLEMENTS = Timepill/Timepill.entitlements; CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = 96T8KJDKQ3; HEADER_SEARCH_PATHS = ( @@ -1646,6 +1712,7 @@ "$(SRCROOT)/../node_modules/react-native-image-resizer/ios/RCTImageResizer", "$(SRCROOT)/../node_modules/react-native-image-crop-picker/ios/**", "$(SRCROOT)/../node_modules/rn-fetch-blob/ios/**", + "$(SRCROOT)/../node_modules/react-native-smart-xgpush/ios/RCTXGPushModule", ); INFOPLIST_FILE = Timepill/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; @@ -1680,6 +1747,7 @@ "$(SRCROOT)/../node_modules/react-native-image-resizer/ios/RCTImageResizer", "$(SRCROOT)/../node_modules/react-native-image-crop-picker/ios/**", "$(SRCROOT)/../node_modules/rn-fetch-blob/ios/**", + "$(SRCROOT)/../node_modules/react-native-smart-xgpush/ios/RCTXGPushModule", ); INFOPLIST_FILE = "Timepill-tvOS/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; @@ -1693,6 +1761,7 @@ "\"$(SRCROOT)/$(TARGET_NAME)\"", "\"$(SRCROOT)/$(TARGET_NAME)\"", "\"$(SRCROOT)/$(TARGET_NAME)\"", + "\"$(SRCROOT)/$(TARGET_NAME)\"", ); OTHER_LDFLAGS = ( "-ObjC", @@ -1726,6 +1795,7 @@ "$(SRCROOT)/../node_modules/react-native-image-resizer/ios/RCTImageResizer", "$(SRCROOT)/../node_modules/react-native-image-crop-picker/ios/**", "$(SRCROOT)/../node_modules/rn-fetch-blob/ios/**", + "$(SRCROOT)/../node_modules/react-native-smart-xgpush/ios/RCTXGPushModule", ); INFOPLIST_FILE = "Timepill-tvOS/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; @@ -1739,6 +1809,7 @@ "\"$(SRCROOT)/$(TARGET_NAME)\"", "\"$(SRCROOT)/$(TARGET_NAME)\"", "\"$(SRCROOT)/$(TARGET_NAME)\"", + "\"$(SRCROOT)/$(TARGET_NAME)\"", ); OTHER_LDFLAGS = ( "-ObjC", @@ -1771,6 +1842,7 @@ "$(SRCROOT)/../node_modules/react-native-image-resizer/ios/RCTImageResizer", "$(SRCROOT)/../node_modules/react-native-image-crop-picker/ios/**", "$(SRCROOT)/../node_modules/rn-fetch-blob/ios/**", + "$(SRCROOT)/../node_modules/react-native-smart-xgpush/ios/RCTXGPushModule", ); INFOPLIST_FILE = "Timepill-tvOSTests/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; @@ -1784,6 +1856,7 @@ "\"$(SRCROOT)/$(TARGET_NAME)\"", "\"$(SRCROOT)/$(TARGET_NAME)\"", "\"$(SRCROOT)/$(TARGET_NAME)\"", + "\"$(SRCROOT)/$(TARGET_NAME)\"", ); OTHER_LDFLAGS = ( "-ObjC", @@ -1816,6 +1889,7 @@ "$(SRCROOT)/../node_modules/react-native-image-resizer/ios/RCTImageResizer", "$(SRCROOT)/../node_modules/react-native-image-crop-picker/ios/**", "$(SRCROOT)/../node_modules/rn-fetch-blob/ios/**", + "$(SRCROOT)/../node_modules/react-native-smart-xgpush/ios/RCTXGPushModule", ); INFOPLIST_FILE = "Timepill-tvOSTests/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; @@ -1829,6 +1903,7 @@ "\"$(SRCROOT)/$(TARGET_NAME)\"", "\"$(SRCROOT)/$(TARGET_NAME)\"", "\"$(SRCROOT)/$(TARGET_NAME)\"", + "\"$(SRCROOT)/$(TARGET_NAME)\"", ); OTHER_LDFLAGS = ( "-ObjC", diff --git a/ios/Timepill.xcodeproj/xcshareddata/xcschemes/Timepill.xcscheme b/ios/Timepill.xcodeproj/xcshareddata/xcschemes/Timepill.xcscheme index 0a54ae1..e4233da 100644 --- a/ios/Timepill.xcodeproj/xcshareddata/xcschemes/Timepill.xcscheme +++ b/ios/Timepill.xcodeproj/xcshareddata/xcschemes/Timepill.xcscheme @@ -103,7 +103,7 @@ + isEnabled = "NO"> diff --git a/ios/Timepill/AppDelegate.m b/ios/Timepill/AppDelegate.m index 3c58aad..03e81f1 100644 --- a/ios/Timepill/AppDelegate.m +++ b/ios/Timepill/AppDelegate.m @@ -11,14 +11,133 @@ #import #import +#import "XGPush.h" +#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0 +#import +#endif +#import "RCTXGPushModule.h" + +@interface AppDelegate () +@end + @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + + [[XGPush defaultManager] setEnableDebug:YES]; + XGNotificationAction *action1 = [XGNotificationAction actionWithIdentifier:@"xgaction001" title:@"xgAction1" options:XGNotificationActionOptionNone]; + XGNotificationAction *action2 = [XGNotificationAction actionWithIdentifier:@"xgaction002" title:@"xgAction2" options:XGNotificationActionOptionDestructive]; + XGNotificationCategory *category = [XGNotificationCategory categoryWithIdentifier:@"xgCategory" actions:@[action1, action2] intentIdentifiers:@[] options:XGNotificationCategoryOptionNone]; + XGNotificationConfigure *configure = [XGNotificationConfigure configureNotificationWithCategories:nil types:XGUserNotificationTypeAlert|XGUserNotificationTypeBadge|XGUserNotificationTypeSound]; + [[XGPush defaultManager] setNotificationConfigure:configure]; + [[XGPush defaultManager] startXGWithAppID:2200337125 appKey:@"IN15RCD511ZK" delegate:self]; + [[XGPush defaultManager] setXgApplicationBadgeNumber:0]; + [[XGPush defaultManager] reportXGNotificationInfo:launchOptions]; + NSURL *jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil]; [ReactNativeNavigation bootstrap:jsCodeLocation launchOptions:launchOptions]; return YES; } +-(void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error{ + NSLog(@"[XGDemo] register APNS fail.\n[XGDemo] reason : %@", error); + [[NSNotificationCenter defaultCenter] postNotificationName:@"registerDeviceFailed" object:nil]; +} + +/** + 收到通知的回调 + + @param application UIApplication 实例 + @param userInfo 推送时指定的参数 + */ +- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo { + NSLog(@"[XGDemo] receive Notification"); + [[XGPush defaultManager] reportXGNotificationInfo:userInfo]; + NSLog(@"ios 9 "); + if( [UIApplication sharedApplication].applicationState == UIApplicationStateActive) + { + //NSLog(@"didReceiveRemoteNotification:APP在前台运行时,不做处理"); + [[NSNotificationCenter defaultCenter] postNotificationName:kJPFDidReceiveRemoteNotification object:userInfo]; + }//当APP在后台运行时,当有通知栏消息时,点击它,就会执行下面的方法跳转到相应的页面 + else if([UIApplication sharedApplication].applicationState == UIApplicationStateInactive){ + // 取得 APNs 标准信息内容 + //NSLog(@"didReceiveRemoteNotification:APP在后台运行时,当有通知栏消息时,点击它,就会执行下面的方法跳转到相应的页面"); + [[NSNotificationCenter defaultCenter] postNotificationName:kJPFOpenNotification object:userInfo]; + } + +} + +/** + 收到静默推送的回调 + + @param application UIApplication 实例 + @param userInfo 推送时指定的参数 + @param completionHandler 完成回调 + */ +- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler { + NSLog(@"[XGDemo] receive slient Notification"); + NSLog(@"[XGDemo] userinfo %@", userInfo); + [[XGPush defaultManager] reportXGNotificationInfo:userInfo]; + + if( [UIApplication sharedApplication].applicationState == UIApplicationStateActive) + { + //NSLog(@"didReceiveRemoteNotification:APP在前台运行时,不做处理"); + [[NSNotificationCenter defaultCenter] postNotificationName:kJPFDidReceiveRemoteNotification object:userInfo]; + }//当APP在后台运行时,当有通知栏消息时,点击它,就会执行下面的方法跳转到相应的页面 + else if([UIApplication sharedApplication].applicationState == UIApplicationStateInactive){ + // 取得 APNs 标准信息内容 + //NSLog(@"didReceiveRemoteNotification:APP在后台运行时,当有通知栏消息时,点击它,就会执行下面的方法跳转到相应的页面"); + [[NSNotificationCenter defaultCenter] postNotificationName:kJPFOpenNotification object:userInfo]; + } + + completionHandler(UIBackgroundFetchResultNewData); +} + + +// iOS 10 新增 API +// iOS 10 会走新 API, iOS 10 以前会走到老 API +#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0 +// App 用户点击通知 +// App 用户选择通知中的行为 +// App 用户在通知中心清除消息 +// 无论本地推送还是远程推送都会走这个回调 +- (void)xgPushUserNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler { + NSLog(@"[XGDemo] click notification"); + // if ([response.actionIdentifier isEqualToString:@"xgaction001"]) { + // NSLog(@"click from Action1"); + // } else if ([response.actionIdentifier isEqualToString:@"xgaction002"]) { + // NSLog(@"click from Action2"); + // } + + [[XGPush defaultManager] reportXGNotificationResponse:response]; + NSDictionary * userInfo = response.notification.request.content.userInfo; + // if([response.notification.request.trigger isKindOfClass:[UNPushNotificationTrigger class]]) { + [[XGPush defaultManager] reportXGNotificationInfo:userInfo]; + [[NSNotificationCenter defaultCenter] postNotificationName:kJPFOpenNotification object:userInfo]; + completionHandler(); +} + +// App 在前台弹通知需要调用这个接口 +- (void)xgPushUserNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler { + [[XGPush defaultManager] reportXGNotificationInfo:notification.request.content.userInfo]; + NSLog(@"xgPushUserNotificationCenter"); + NSDictionary * userInfo = notification.request.content.userInfo; + // if([notification.request.trigger isKindOfClass:[UNPushNotificationTrigger class]]) { + [[XGPush defaultManager] reportXGNotificationInfo:userInfo]; + [[NSNotificationCenter defaultCenter] postNotificationName:kJPFDidReceiveRemoteNotification object:userInfo]; + completionHandler(UNNotificationPresentationOptionBadge | UNNotificationPresentationOptionSound | UNNotificationPresentationOptionAlert); +} +#endif + +#pragma mark - XGPushDelegate +- (void)xgPushDidFinishStart:(BOOL)isSuccess error:(NSError *)error { + NSLog(@"%s, result %@, error %@", __FUNCTION__, isSuccess?@"OK":@"NO", error); +} + +- (void)xgPushDidFinishStop:(BOOL)isSuccess error:(NSError *)error { + NSLog(@"%s, result %@, error %@", __FUNCTION__, isSuccess?@"OK":@"NO", error); +} + @end diff --git a/package-lock.json b/package-lock.json index a76e885..b0303c0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5015,7 +5015,8 @@ }, "ansi-regex": { "version": "2.1.1", - "bundled": true + "bundled": true, + "optional": true }, "aproba": { "version": "1.2.0", @@ -5033,11 +5034,13 @@ }, "balanced-match": { "version": "1.0.0", - "bundled": true + "bundled": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -5050,15 +5053,18 @@ }, "code-point-at": { "version": "1.1.0", - "bundled": true + "bundled": true, + "optional": true }, "concat-map": { "version": "0.0.1", - "bundled": true + "bundled": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", - "bundled": true + "bundled": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -5161,7 +5167,8 @@ }, "inherits": { "version": "2.0.3", - "bundled": true + "bundled": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -5171,6 +5178,7 @@ "is-fullwidth-code-point": { "version": "1.0.0", "bundled": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -5183,17 +5191,20 @@ "minimatch": { "version": "3.0.4", "bundled": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } }, "minimist": { "version": "0.0.8", - "bundled": true + "bundled": true, + "optional": true }, "minipass": { "version": "2.3.5", "bundled": true, + "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -5210,6 +5221,7 @@ "mkdirp": { "version": "0.5.1", "bundled": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -5282,7 +5294,8 @@ }, "number-is-nan": { "version": "1.0.1", - "bundled": true + "bundled": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -5292,6 +5305,7 @@ "once": { "version": "1.4.0", "bundled": true, + "optional": true, "requires": { "wrappy": "1" } @@ -5367,7 +5381,8 @@ }, "safe-buffer": { "version": "5.1.2", - "bundled": true + "bundled": true, + "optional": true }, "safer-buffer": { "version": "2.1.2", @@ -5397,6 +5412,7 @@ "string-width": { "version": "1.0.2", "bundled": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -5414,6 +5430,7 @@ "strip-ansi": { "version": "3.0.1", "bundled": true, + "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -5452,11 +5469,13 @@ }, "wrappy": { "version": "1.0.2", - "bundled": true + "bundled": true, + "optional": true }, "yallist": { "version": "3.0.3", - "bundled": true + "bundled": true, + "optional": true } } }, @@ -10908,6 +10927,11 @@ "react-native-root-siblings": "^3.0.0" } }, + "react-native-smart-xgpush": { + "version": "0.0.6", + "resolved": "https://registry.npm.taobao.org/react-native-smart-xgpush/download/react-native-smart-xgpush-0.0.6.tgz", + "integrity": "sha1-pG4VqfBgG6nhlAfZYj/63UnH96I=" + }, "react-native-tab-view": { "version": "1.3.0", "resolved": "https://registry.npm.taobao.org/react-native-tab-view/download/react-native-tab-view-1.3.0.tgz", diff --git a/package.json b/package.json index 6827916..33ee982 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "react-native-keyboard-spacer": "^0.4.1", "react-native-navigation": "^2.18.5", "react-native-root-toast": "^3.0.0", + "react-native-smart-xgpush": "0.0.6", "react-native-tab-view": "^1.3.0", "react-native-vector-icons": "^4.5.0", "rn-fetch-blob": "^0.10.15"