| | |
| | | |
| | | private static void ModifyFile(string projectPath) |
| | | { |
| | | bool _isMr = false; |
| | | string _mrPlistPath = Application.dataPath + "/Plugins/iOS/MyMRSDK/MRSDKInfo.plist"; |
| | | if (File.Exists(_mrPlistPath)) |
| | | { |
| | | _isMr = true; |
| | | } |
| | | |
| | | // -------------- UnityAppController.mm |
| | | //读取UnityAppController.mm文件 |
| | | var _xclass = new XClass(projectPath + "/Classes/UnityAppController.mm"); |
| | | |
| | | //在指定代码后面增加一行代码 |
| | | _xclass.WriteBelow("#include \"PluginBase/AppDelegateListener.h\"", "#include \"UniversalSDK.h\"\n#include \"JPushService.h\"\n#include \"IAPManager.h\""); |
| | | _xclass.WriteBelow("#include \"PluginBase/AppDelegateListener.h\"", "#include \"UniversalSDK.h\"\n#include \"JPushService.h\"\n"); |
| | | |
| | | if (_isMr) |
| | | { |
| | | _xclass.WriteBelow("#include \"PluginBase/AppDelegateListener.h\"", "#include \"IAPManager.h\"\n"); |
| | | } |
| | | |
| | | string newCode = "\n" + |
| | | "extern \"C\" void IOSMessageHandle(const char* jsonString) {\n" + |
| | |
| | | newCode); |
| | | |
| | | newCode = "\n" + |
| | | " [[IAPManager shared] startManager];\n" + |
| | | " _universalSDK = [[UniversalSDK alloc] init];\n" + |
| | | " [_universalSDK JPushInit:launchOptions];"; |
| | | |
| | | //在指定代码后面增加一大行代码 |
| | | _xclass.WriteBelow("[KeyboardDelegate Initialize];", newCode); |
| | | |
| | | if (_isMr) |
| | | { |
| | | _xclass.WriteBelow("[KeyboardDelegate Initialize];", " [[IAPManager shared] startManager];\n"); |
| | | } |
| | | |
| | | _xclass.WriteBelow("UnitySendDeviceToken(deviceToken);", " [JPUSHService registerDeviceToken:deviceToken];"); |
| | | _xclass.WriteBelow("SensorsCleanup();", " [[IAPManager shared] startManager];"); |
| | | |
| | | if (_isMr) |
| | | { |
| | | _xclass.WriteBelow("SensorsCleanup();", " [[IAPManager shared] stopManager];"); |
| | | } |
| | | |
| | | newCode = "UnitySendRemoteNotification(userInfo);\n" + |
| | | " [JPUSHService handleRemoteNotification:userInfo];\n"; |