{"id":20732423,"url":"https://github.com/jpush/jpush-unity3d-plugin","last_synced_at":"2025-04-13T06:35:08.947Z","repository":{"id":16055075,"uuid":"18799210","full_name":"jpush/jpush-unity3d-plugin","owner":"jpush","description":"JPush's officially supported Unity3d plugin (Android \u0026 iOS). 极光推送官方支持的 Unity3d 插件（Android \u0026 iOS）。","archived":false,"fork":false,"pushed_at":"2024-07-11T04:20:49.000Z","size":384926,"stargazers_count":114,"open_issues_count":21,"forks_count":51,"subscribers_count":35,"default_branch":"master","last_synced_at":"2025-03-24T09:44:14.864Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://docs.jiguang.cn","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jpush.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-04-15T12:30:07.000Z","updated_at":"2024-07-11T04:20:53.000Z","dependencies_parsed_at":"2024-04-24T09:52:59.721Z","dependency_job_id":"445d9400-b0cc-4705-a610-9e7484822271","html_url":"https://github.com/jpush/jpush-unity3d-plugin","commit_stats":null,"previous_names":[],"tags_count":24,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpush%2Fjpush-unity3d-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpush%2Fjpush-unity3d-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpush%2Fjpush-unity3d-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpush%2Fjpush-unity3d-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jpush","download_url":"https://codeload.github.com/jpush/jpush-unity3d-plugin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248674998,"owners_count":21143761,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-17T05:19:22.006Z","updated_at":"2025-04-13T06:35:08.919Z","avatar_url":"https://github.com/jpush.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JPush Unity Plugin\n\n[![release](https://img.shields.io/badge/release-3.2.0-blue.svg)](https://github.com/jpush/jpush-unity3d-plugin/releases)\n[![platforms](https://img.shields.io/badge/platforms-iOS%7CAndroid-green.svg)](https://github.com/jpush/jpush-unity3d-plugin)\n\n这是极光官方支持的 JPush Unity 插件（Android \u0026amp; iOS）。\n\n## 集成\n\n把Plugins文件夹里的文件合并到您自己的项目Assets/Plugins文件夹下面\n\n### Android\n\n1. 生成build文件：\n   在 Unity 中选择 *File---Build Settings---Player Settings*\n   ---Publishing Settings ---- Build 勾上选以下选项下：\n*  Custom Launcher Gradle Template\n##### 会生成以下文件\n*  launcherTemplate.gradle文件\n#### 修改launcherTemplate.gradle文件：\n- 在dependencies里面加\n```\n    implementation 'cn.jiguang.sdk:jpush:4.9.0'  // 此处以JPush 4.9.0 版本为例。\n    implementation 'cn.jiguang.sdk:jcore:4.1.0'  // 此处以JCore 4.1.0 版本为例。\n```\n- 在defaultConfig里面加,并填写对应信息\n```\n manifestPlaceholders = [\n                JPUSH_PKGNAME : applicationId,\n                JPUSH_APPKEY : \"你的 Appkey \", //JPush 上注册的包名对应的 Appkey.\n                JPUSH_CHANNEL : \"developer-default\", //暂时填写默认值即可.\n        ]\n```\n具体可参考Examples下  launcherTemplate.gradle 文件\n\n2. 配置项目里的包名：在 Unity 中选择 *File---Build Settings---Player Settings*，将 *Identification* 选项下的 *Bundle Identifier* 设置为应用的包名。\n\n### iOS\n\n1. 生成 iOS 工程，并打开该工程。\n2. 添加必要的框架：\n   - CFNetwork.framework\n   - CoreFoundation.framework\n   - CoreTelephony.framework\n   - SystemConfiguration.framework\n   - CoreGraphics.framework\n   - Foundation.framework\n   - UIKit.framework\n   - Security.framework\n   - libz.tbd（Xcode 7 以下版本是 libz.dylib）\n   - AdSupport.framework（获取 IDFA 需要；如果不使用 IDFA，请不要添加）\n   - UserNotifications.framework（Xcode 8 及以上）\n   - libresolv.tbd（JPush 2.2.0 及以上版本需要，Xcode 7 以下版本是 libresolv.dylib）\n   - WebKit.framework（JPush 3.3.0 及以上版本需要）\n   - AppTrackingTransparency.framework(Xcode 12 及以上，获取 IDFA 需要；如果不使用 IDFA，请不要添加)\n   - StoreKit.framework(JPush 3.3.6 及以上版本需要)\n\n\n      ​\n\n3. 在 UnityAppController.mm 中添加头文件 `JPUSHService.h`  。\n\n    ```Objective-C\n    #import \"JPUSHService.h\"\n    #import \"JPushEventCache.h\"\n    #import \u003cUserNotifications/UserNotifications.h\u003e\n\n    // 如需使用广告标识符 IDFA 则添加该头文件，否则不添加。\n    #import \u003cAdSupport/AdSupport.h\u003e\n\n    @interface UnityAppController ()\n    @end\n    ```\n\n4. 在 UnityAppController.mm 的下列方法中添加以下代码：\n\n    ```Objective-C\n    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {\n\n      [[JPushEventCache sharedInstance] handFinishLaunchOption:launchOptions];\n      /*\n        不使用 IDFA 启动 SDK。\n        参数说明：\n            appKey: 极光官网控制台应用标识。\n            channel: 频道，暂无可填任意。\n            apsForProduction: YES: 发布环境；NO: 开发环境。\n      */\n      [JPUSHService setupWithOption:launchOptions appKey:@\"abcacdf406411fa656ee11c3\" channel:@\"\" apsForProduction:NO];\n\n      /*\n        使用 IDFA 启动 SDK（不能与上述方法同时使用）。\n        参数说明：\n            appKey: 极光官网控制台应用标识。\n            channel: 频道，暂无可填任意。\n            apsForProduction: YES: 发布环境；NO: 开发环境。\n            advertisingIdentifier: IDFA广告标识符。根据自身情况选择是否带有 IDFA 的启动方法，并注释另外一个启动方法。\n      */\n    //  NSString *advertisingId = [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString];\n    //  [JPUSHService setupWithOption:launchOptions appKey:@\"替换成你自己的 Appkey\" channel:@\"\" apsForProduction:NO SadvertisingIdentifier:advertisingId];\n\n      return YES;\n    }\n\n    - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {\n      // Required.\n      [JPUSHService registerDeviceToken:deviceToken];\n    }\n\n    - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {\n      // Required.\n      [[JPushEventCache sharedInstance] sendEvent:userInfo withKey:@\"JPushPluginReceiveNotification\"];\n      [JPUSHService handleRemoteNotification:userInfo];\n    }\n\n    - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))handler {\n      [[JPushEventCache sharedInstance] sendEvent:userInfo withKey:@\"JPushPluginReceiveNotification\"];\n    }\n    ```\n    \n5.有些Unity版本在导出Xcode项目之后，需要修改：\n\n```Objective-C\n    Preprocessor.h 文件中\n\n    #define UNITY_USES_REMOTE_NOTIFICATIONS 0\n    更改为\n    #define UNITY_USES_REMOTE_NOTIFICATIONS 1\n\n    否则\n\n    didReceiveRemoteNotification\n    didRegisterForRemoteNotificationsWithDeviceToken\n    didReceiveRemoteNotification\n\n    都将无法使用\n```\n## API 说明\n\nAndroid 与 iOS [通用 API](/Doc/CommonAPI.md)。\n\n### Android\n\n[Android API](/Doc/AndroidAPI.md)\n\n\u003e ./Plugins/Android/jpush-unity-plugin 为插件的 Android 项目，可以使用 Android Studio 打开并进行修改（比如，targetSdkVersion 或者 minSdkVersion），再 build 为 .aar 替换已有的 jpush.aar。\n\n### iOS\n\n[iOS API](/Doc/iOSAPI.md)\n\n## 更多\n\n- [JPush 官网文档](http://docs.jiguang.cn/guideline/jpush_guide/)\n- 有问题可访问[极光社区](http://community.jpush.cn/)搜索和提问。\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjpush%2Fjpush-unity3d-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjpush%2Fjpush-unity3d-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjpush%2Fjpush-unity3d-plugin/lists"}