Code Monkey home page Code Monkey logo

jpush-unity3d-plugin's Introduction

JPush Unity Plugin

release platforms

这是极光官方支持的 JPush Unity 插件(Android & iOS)。

集成

把Plugins文件夹里的文件合并到您自己的项目Assets/Plugins文件夹下面

Android

  1. 生成build文件: 在 Unity 中选择 File---Build Settings---Player Settings ---Publishing Settings ---- Build 勾上选以下选项下:
  • Custom Launcher Gradle Template
会生成以下文件
  • launcherTemplate.gradle文件

修改launcherTemplate.gradle文件:

  • 在dependencies里面加
    implementation 'cn.jiguang.sdk:jpush:4.9.0'  // 此处以JPush 4.9.0 版本为例。
    implementation 'cn.jiguang.sdk:jcore:4.1.0'  // 此处以JCore 4.1.0 版本为例。
  • 在defaultConfig里面加,并填写对应信息
 manifestPlaceholders = [
                JPUSH_PKGNAME : applicationId,
                JPUSH_APPKEY : "你的 Appkey ", //JPush 上注册的包名对应的 Appkey.
                JPUSH_CHANNEL : "developer-default", //暂时填写默认值即可.
        ]

具体可参考Examples下 launcherTemplate.gradle 文件

  1. 配置项目里的包名:在 Unity 中选择 File---Build Settings---Player Settings,将 Identification 选项下的 Bundle Identifier 设置为应用的包名。

iOS

  1. 生成 iOS 工程,并打开该工程。

  2. 添加必要的框架:

    • CFNetwork.framework

    • CoreFoundation.framework

    • CoreTelephony.framework

    • SystemConfiguration.framework

    • CoreGraphics.framework

    • Foundation.framework

    • UIKit.framework

    • Security.framework

    • libz.tbd(Xcode 7 以下版本是 libz.dylib)

    • AdSupport.framework(获取 IDFA 需要;如果不使用 IDFA,请不要添加)

    • UserNotifications.framework(Xcode 8 及以上)

    • libresolv.tbd(JPush 2.2.0 及以上版本需要,Xcode 7 以下版本是 libresolv.dylib)

    • WebKit.framework(JPush 3.3.0 及以上版本需要)

    • AppTrackingTransparency.framework(Xcode 12 及以上,获取 IDFA 需要;如果不使用 IDFA,请不要添加)

    • StoreKit.framework(JPush 3.3.6 及以上版本需要)

  3. 在 UnityAppController.mm 中添加头文件 JPUSHService.h

    #import "JPUSHService.h"
    #import "JPushEventCache.h"
    #import <UserNotifications/UserNotifications.h>
    
    // 如需使用广告标识符 IDFA 则添加该头文件,否则不添加。
    #import <AdSupport/AdSupport.h>
    
    @interface UnityAppController ()
    @end
  4. 在 UnityAppController.mm 的下列方法中添加以下代码:

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    
      [[JPushEventCache sharedInstance] handFinishLaunchOption:launchOptions];
      /*
        不使用 IDFA 启动 SDK。
        参数说明:
            appKey: 极光官网控制台应用标识。
            channel: 频道,暂无可填任意。
            apsForProduction: YES: 发布环境;NO: 开发环境。
      */
      [JPUSHService setupWithOption:launchOptions appKey:@"abcacdf406411fa656ee11c3" channel:@"" apsForProduction:NO];
    
      /*
        使用 IDFA 启动 SDK(不能与上述方法同时使用)。
        参数说明:
            appKey: 极光官网控制台应用标识。
            channel: 频道,暂无可填任意。
            apsForProduction: YES: 发布环境;NO: 开发环境。
            advertisingIdentifier: IDFA广告标识符。根据自身情况选择是否带有 IDFA 的启动方法,并注释另外一个启动方法。
      */
    //  NSString *advertisingId = [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString];
    //  [JPUSHService setupWithOption:launchOptions appKey:@"替换成你自己的 Appkey" channel:@"" apsForProduction:NO SadvertisingIdentifier:advertisingId];
    
      return YES;
    }
    
    - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
      // Required.
      [JPUSHService registerDeviceToken:deviceToken];
    }
    
    - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
      // Required.
      [[JPushEventCache sharedInstance] sendEvent:userInfo withKey:@"JPushPluginReceiveNotification"];
      [JPUSHService handleRemoteNotification:userInfo];
    }
    
    - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))handler {
      [[JPushEventCache sharedInstance] sendEvent:userInfo withKey:@"JPushPluginReceiveNotification"];
    }

5.有些Unity版本在导出Xcode项目之后,需要修改:

    Preprocessor.h 文件中

    #define UNITY_USES_REMOTE_NOTIFICATIONS 0
    更改为
    #define UNITY_USES_REMOTE_NOTIFICATIONS 1

    否则

    didReceiveRemoteNotification
    didRegisterForRemoteNotificationsWithDeviceToken
    didReceiveRemoteNotification

    都将无法使用

API 说明

Android 与 iOS 通用 API

Android

Android API

./Plugins/Android/jpush-unity-plugin 为插件的 Android 项目,可以使用 Android Studio 打开并进行修改(比如,targetSdkVersion 或者 minSdkVersion),再 build 为 .aar 替换已有的 jpush.aar。

iOS

iOS API

更多

jpush-unity3d-plugin's People

Contributors

huangminlinux avatar huangshuni avatar javenfang avatar joshlipan avatar lcterry avatar lhw5123 avatar logiczhang avatar pikacode avatar pkjueying avatar weiruiyang avatar zhangqinghe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jpush-unity3d-plugin's Issues

库按教程添加了,编译还是报错

Undefined symbols for architecture arm64:
"_g_typeDefinitionSize3800", referenced from:
_g_Il2CppTypeDefinitionSizesTable in Il2CppCompilerCalculateTypeValuesTable.o
"_g_typeDefinitionSize3801", referenced from:
_g_Il2CppTypeDefinitionSizesTable in Il2CppCompilerCalculateTypeValuesTable.o

PluginsDemo.cs中使用了一个变量params,和关键字重了啊

#if UNITY_IPHONE || UNITY_IOS
if (GUILayout.Button("Trigger local notification after 3 seconds", GUILayout.Height(80)))
{
JsonData params = new JsonData();
params["title"] = "the title";
params["id"] = 5;
params["content"] = "the content";
params["badge"] = 9;
TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
long ret = Convert.ToInt64(ts.TotalSeconds) + 3;
params["fireTime"] = ret;
params["subtitle"] = "the subtitle";
JPushBinding.SendLocalNotification(params.ToJson());
}
#endif

duplicate symbol '_CreateNSString'

ld: warning: arm64 function not 4-byte aligned: _unwind_tester from 
.........../Libraries/libiPhone-lib.a(unwind_test_arm64.o)
duplicate symbol '_CreateNSString' in:
    ............../arm64/JPushUnityManager.o
    ................/umeng_analytics/libUMUnityAnalytics.a(UMUnityAnalytics.o)
ld: 1 duplicate symbol for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
```
看起来JPushUnityManager 和友盟的UnityAnalytics重叠了一个方法啊。看看能否更改一个名字?

UnityPluginActivity中的代码作用?

https://github.com/jpush/jpush-unity3d-plugin/blob/master/Plugins/Android/src/UnityPluginActivity.java
这个文件中
WindowManager.LayoutParams attr = getWindow().getAttributes();
attr.flags &= (~WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().setAttributes(attr);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);

这4句代码是干嘛的?强行让app不能全屏?
目前我们用该插件打出来的包,游戏多出来黑边

因為目前Plugin只有iOS/Android,JPushBinding.cs的Platform Compile應該要修改

例如:
`public static void Init(string gameObject)
{
#if UNITY_ANDROID
_plugin.Call("initPush", gameObject);

        #elif UNITY_IOS
        _init(gameObject);
		
        #endif
	}`

要改成:
`public static void Init(string gameObject)
{
#if UNITY_ANDROID && !UNITY_EDITOR
_plugin.Call("initPush", gameObject);

        #elif UNITY_IOS && !UNITY_EDITOR
        _init(gameObject);
		
        #endif
	}`

否則在編輯器裡面執行都會有runtime EntryPointNotFoundException

Exception: JNI: Init'd AndroidJavaClass with null ptr!

using(AndroidJavaClass jpushClass = new AndroidJavaClass("com.example.unity3d_jpush_demo.JPushBridge"))
step to reproduce

  1. Create new project
  2. import plugin
  3. update AndroidManifest.xml package id
  4. add Game object in Scene, add JPushBridge to component
  5. build and run android
  6. error occure

安卓4,5版本,无法接受本地通知。

安卓4,5版本,无法接受本地通知。
感觉像初始化失败。

安卓7,8与IOS都能正常接受。

==============================================================
05-28 16:18:44.632 917-917/? I/WorkerManager: New handler created for worker [service] (manager: 4a95d2cc, handler: 4a95d324)
05-28 16:18:44.632 917-917/? I/WorkerHandler: New state for worker [service]: c (handler: 4a95d324)
05-28 16:18:44.652 917-986/? I/dalvikvm: Could not find method android.content.Context.checkSelfPermission, referenced from method com.google.android.apps.gsa.shared.util.permissions.a.a.a
05-28 16:18:44.652 917-986/? W/dalvikvm: VFY: unable to resolve virtual method 1312: Landroid/content/Context;.checkSelfPermission (Ljava/lang/String;)I
05-28 16:18:44.662 917-986/? W/dalvikvm: VFY: unable to find class referenced in signature (Landroid/app/NotificationChannel;)
05-28 16:18:44.662 917-986/? W/dalvikvm: VFY: unable to find class referenced in signature (Landroid/app/NotificationChannel;)
05-28 16:18:44.662 917-986/? E/dalvikvm: Could not find class 'android.app.NotificationChannel', referenced from method com.google.android.apps.gsa.search.core.am.a
05-28 16:18:44.662 917-986/? W/dalvikvm: VFY: unable to resolve check-cast 182 (Landroid/app/NotificationChannel;) in Lcom/google/android/apps/gsa/search/core/am;
05-28 16:18:44.662 917-986/? W/dalvikvm: VFY: unable to find class referenced in signature (Landroid/app/NotificationChannel;)
05-28 16:18:44.662 917-986/? W/dalvikvm: VFY: unable to find class referenced in signature (Landroid/app/NotificationChannel;)
05-28 16:18:44.672 917-986/? W/dalvikvm: VFY: unable to find class referenced in signature (Landroid/net/Network;)
05-28 16:18:44.672 917-986/? I/dalvikvm: Could not find method android.net.ConnectivityManager.getNetworkInfo, referenced from method com.google.android.libraries.gsa.d.a.b.aa.a
05-28 16:18:44.672 917-986/? W/dalvikvm: VFY: unable to resolve virtual method 1208: Landroid/net/ConnectivityManager;.getNetworkInfo (Landroid/net/Network;)Landroid/net/NetworkInfo;
05-28 16:18:44.672 917-986/? I/dalvikvm: Could not find method android.net.ConnectivityManager.getRestrictBackgroundStatus, referenced from method com.google.android.libraries.gsa.d.a.b.aa.c
05-28 16:18:44.672 917-986/? W/dalvikvm: VFY: unable to resolve virtual method 1209: Landroid/net/ConnectivityManager;.getRestrictBackgroundStatus ()I
05-28 16:18:44.672 917-986/? W/dalvikvm: VFY: unable to find class referenced in signature (Landroid/net/Network;)
05-28 16:18:44.672 917-986/? W/dalvikvm: VFY: unable to find class referenced in signature (Landroid/net/Network;)
05-28 16:18:44.672 917-986/? W/dalvikvm: VFY: unable to find class referenced in signature (Landroid/net/Network;)
05-28 16:18:44.672 917-986/? W/dalvikvm: VFY: unable to find class referenced in signature (Landroid/net/Network;)
05-28 16:18:44.672 917-986/? W/dalvikvm: VFY: unable to find class referenced in signature (Landroid/net/Network;)
05-28 16:18:44.672 917-986/? I/dalvikvm: Could not find method android.net.Network.equals, referenced from method com.google.android.libraries.gsa.d.a.b.b.equals
05-28 16:18:44.672 917-986/? W/dalvikvm: VFY: unable to resolve virtual method 1215: Landroid/net/Network;.equals (Ljava/lang/Object;)Z
05-28 16:18:44.672 917-986/? W/dalvikvm: VFY: unable to find class referenced in signature (Landroid/net/Network;)
05-28 16:18:44.672 917-986/? I/dalvikvm: Could not find method android.net.Network.hashCode, referenced from method com.google.android.libraries.gsa.d.a.b.b.hashCode
05-28 16:18:44.672 917-986/? W/dalvikvm: VFY: unable to resolve virtual method 1216: Landroid/net/Network;.hashCode ()I
05-28 16:18:44.672 917-986/? W/dalvikvm: Unable to resolve superclass of Lcom/google/android/libraries/gsa/d/a/b/e; (283)
05-28 16:18:44.672 917-986/? W/dalvikvm: Link of class 'Lcom/google/android/libraries/gsa/d/a/b/e;' failed
05-28 16:18:44.672 917-986/? E/dalvikvm: Could not find class 'com.google.android.libraries.gsa.d.a.b.e', referenced from method com.google.android.libraries.gsa.d.a.b.d.a
05-28 16:18:44.672 917-986/? W/dalvikvm: VFY: unable to resolve new-instance 15516 (Lcom/google/android/libraries/gsa/d/a/b/e;) in Lcom/google/android/libraries/gsa/d/a/b/d;
05-28 16:18:44.672 917-986/? I/dalvikvm: Could not find method android.net.ConnectivityManager.unregisterNetworkCallback, referenced from method com.google.android.libraries.gsa.d.a.b.d.b
05-28 16:18:44.672 917-986/? W/dalvikvm: VFY: unable to resolve virtual method 1214: Landroid/net/ConnectivityManager;.unregisterNetworkCallback (Landroid/net/ConnectivityManager$NetworkCallback;)V
05-28 16:18:44.672 917-986/? W/dalvikvm: Unable to resolve superclass of Lcom/google/android/libraries/gsa/d/a/b/e; (283)
05-28 16:18:44.672 917-986/? W/dalvikvm: Link of class 'Lcom/google/android/libraries/gsa/d/a/b/e;' failed
05-28 16:18:44.682 917-986/? I/dalvikvm: Could not find method android.app.NotificationManager.areNotificationsEnabled, referenced from method android.support.v4.app.cu.a
05-28 16:18:44.682 917-986/? W/dalvikvm: VFY: unable to resolve virtual method 834: Landroid/app/NotificationManager;.areNotificationsEnabled ()Z
05-28 16:18:44.682 917-986/? I/WorkerManager: New handler created for worker [backgroundtask] (manager: 4a95d2cc, handler: 4aa2d9c0)
05-28 16:18:44.682 917-986/? I/WorkerHandler: New state for worker [backgroundtask]: c (handler: 4aa2d9c0)
05-28 16:18:44.692 917-986/? I/WorkerManager: New handler created for worker [searchplate] (manager: 4a95d2cc, handler: 4a9508d8)
05-28 16:18:44.692 917-986/? I/WorkerHandler: New state for worker [searchplate]: c (handler: 4a9508d8)
05-28 16:18:44.692 917-996/? W/InstanceID: Instance ID SDK is deprecated, com.google.android.googlequicksearchbox should update to use Firebase Instance ID
05-28 16:18:44.692 917-996/? W/OptInChecker: Missing cached UDC setting for NOW_CARDS
05-28 16:18:44.702 917-996/? I/OptInChecker: Falling back to non-UDC sources
05-28 16:18:44.702 917-996/? I/OptInChecker: Setting = NOW_CARDS, optedInt = true
05-28 16:18:44.722 917-983/? I/OptInChecker: UDC thinks - Setting = WEB_AND_APP_HISTORY, Eligibility = ELIGIBLE
05-28 16:18:44.722 917-983/? I/OptInChecker: Using UDC cache for Setting: WEB_AND_APP_HISTORY
05-28 16:18:44.722 917-983/? I/OptInChecker: UDC Setting = WEB_AND_APP_HISTORY, optedIn = false
05-28 16:18:44.742 2246-2261/? I/dalvikvm: Could not find method android.webkit.WebSettings.setMixedContentMode, referenced from method cn.jpush.android.d.a.a
05-28 16:18:44.742 2246-2261/? W/dalvikvm: VFY: unable to resolve virtual method 11056: Landroid/webkit/WebSettings;.setMixedContentMode (I)V
05-28 16:18:44.812 2246-2331/? E/JIGUANG-JCore: [AndroidUtil] The permissoin is required - android.permission.WRITE_EXTERNAL_STORAGE
05-28 16:18:44.822 2246-2331/? W/JIGUANG-JCore: [JCoreGlobal] JCore init code = 10
05-28 16:18:44.822 2246-2331/? W/JIGUANG-JCore: [JCoreGlobal] JCore init code = 10
05-28 16:18:44.822 2246-2331/? W/JIGUANG-JCore: [PushService] onCreate:JCoreInterface init failed
05-28 16:18:44.822 2246-2331/? W/JIGUANG-JCore: [JCoreGlobal] JCore init code = 10
05-28 16:18:44.822 2246-2331/? W/JIGUANG-JCore: [JCoreGlobal] JCore init code = 10

AddLocalNotificationByDate 接口延时没有用

System.DateTime date=System.DateTime.Now;
Debug.Log("tjtest NotificationMessage:"+date.Year+" "+date.Month+" "+date.Day+" "+date.Hour+" "+date.Minute+" "+date.Second);
JPushBinding.AddLocalNotificationByDate(0, "内容", "标题1111", 1,date.Year, date.Month, date.Day, date.Hour, date.Minute, 59, "");

AddLocalNotificationByDate 这个接口如果设置时间比现在早,就立即推送,但是一但设置的晚于现在时间,就不会推送了,感觉是闹钟出现了问题

有没有Xamarin.iOS的例子

官网只有安卓的绑定库例子,其他网上的iOS绑定使用以及很老了,求官方Xamarin+iOS的绑定库

Unity3d 添加自定义样式

unity3d 添加自定义通知栏不起作用。

public static void setBasicPushNotificationBuilder(string gameObject,string func)
        {
            Debug.Log("unity---setBasicPushNotificationBuilder");
            // 需要根据自己业务情况修改后再调用。
            int builderId = 1;
            int notiDefaults = notificationDefaults | DEFAULT_ALL;
            int notiFlags = notificationFlags | FLAG_AUTO_CANCEL;
            _plugin.Call("setBasicPushNotificationBuilder", gameObject, func,
                builderId, notiDefaults, notiFlags, null);
        }

        public static void setCustomPushNotificationBuilder()
        {
            setCustomPushNotificationBuilder(_gameObject, _func);
        }

        public static void setCustomPushNotificationBuilder(string gameObject,
                string func)
        {
            Debug.Log("unity---setCustomPushNotificationBuilder");
            int builderId = 1;
                        // 这个参数代表什么意义,应该在哪里配置
            string layoutName = "yourNotificationLayoutName";
            // 指定最顶层状态栏小图标, 这个应该怎么配置 
            string statusBarDrawableName = "yourStatusBarDrawableName";
            // 指定下拉状态栏时显示的通知图标   这个应该怎么配置 
            string layoutIconDrawableName = "yourLayoutIconDrawableName";
            _plugin.Call("setCustomPushNotificationBuilder", builderId,
                layoutName, statusBarDrawableName, layoutIconDrawableName);
        }

问题一:只修改setBasicPushNotificationBuilder ,调用 addLocalNotification() 采用样式1没有反应。
问题二:如何修改样式栏弹出的声音。
问题三:

public static void setCustomPushNotificationBuilder(string gameObject,string func)
        {
            Debug.Log("unity---setCustomPushNotificationBuilder");
            int builderId = 1;
                        // 这个参数代表什么意义,应该在哪里配置
            string layoutName = "yourNotificationLayoutName";
            // 指定最顶层状态栏小图标, 这个应该怎么配置 
            string statusBarDrawableName = "yourStatusBarDrawableName";
            // 指定下拉状态栏时显示的通知图标   这个应该怎么配置 
            string layoutIconDrawableName = "yourLayoutIconDrawableName";
            _plugin.Call("setCustomPushNotificationBuilder", builderId,
                layoutName, statusBarDrawableName, layoutIconDrawableName);
        }

这段代码中的 layoutName statusBarDrawableName layoutIconDrawableName 分别代表什么意义,应该怎么配置,才能实现自定义样式。

Unity 2018.3 iOS的UnityAppController.mm內容不符合新標準

在2018.3的環境底下無法正常build iOS了

目前發現兩個更改點:
[[DisplayManager Instance] updateDisplayListInUnity];

已不存在,依照新版本:
[[DisplayManager Instance] updateDisplayListCacheInUnity];

另外:
class_replaceMethod([UIScreen class], @selector(nativeScale), UIScreen_NativeScale_IMP, UIScreen_nativeScale_Enc);

裡面的
UIScreen_nativeScale_Enc 已無法使用。

Unity 2018.3.6 踩坑实录

1.manifest自己手动merge
2.手动下载最新安卓SDK,并把里面的libs, res, so复制到工程里,并且把源码JPushBridge.java,JPushReceiver.java,JPushEventReceiver.java复制到工程里,不要用aar
3.不确定这一点必要与否,反正我把JPushBinding的static全删了,构造函数挪到Awake里,变成了单实例
4.IOS要把一个UNITY_USE_REMOTE_NOTIFICATION宏定义删了

关于ios取消指定id推送消息的接口问题

根据官方文档介绍,推荐使用JPushBinding.SendLocalNotification(json)这个接口,但是这个接口是否无法通过DeleteLocalNotificationWithIdentifierKey(idkey)来取消制定推送?我自己试了是无法取消

java.lang.NullPointerException Crash

Caused by: java.lang.NullPointerException
at cn.jiguang.unity.push.JPushEventReceiver.onTagOperatorResult(JPushEventReceiver.java:39)
at cn.jpush.android.a.b.run(Unknown Source)
at android.os.Handler.handleCallback(Handler.java:733)

安卓上跑了闪退

下载jpush unity 3.1.4,倒入unity5.6.2f1,android manifest手动倒入,添加一个JPush GameObject,JPush.JPushBinding.Init("JPush");,打包成apk。在安卓上安装正常,开启跑,过了splash后,直接闪退。请大神帮帮忙,不知道哪里出了问题。附件是用的manifest
AndroidManifest_copy.txt

setBroadcastTime超过某个阀值后,会立刻推送出来

你好,在安卓上调用这个接口 AddLocalNotification设置延时X秒后进行推送。

如果设置30天(2592000秒)会立即推送出来,我测试当超过2200000秒后,就会立即把消息推送出来。

我使用的是JPushUnityPlugin_v3.2.6.unitypackage

aar中包含的sdk版本为:

jpush-android-3.1.5.jar
jcore-android-1.2.3.jar

我的代码

JPushBinding.AddLocalNotification(0, "推送内容", "标题", 1, 2592000, "");

设置20天后推送adb日志

10-15 19:57:05.476: D/JIGUANG-JPush(9359): [JPushDataAction] Action - onActionRun
10-15 19:57:05.476: D/JIGUANG-JPush(9359): [PushServiceCore] bundle:Bundle[{sdktype=JPUSH, action=org.qing.jpush.intent.MULTI_PROCESS, multi_type=6, local_notification=cn.jpush.android.data.JPushLocalNotification@1}]
10-15 19:57:05.476: D/JIGUANG-JPush(9359): [PushServiceCore] Action - handleServiceAction - action:org.qing.jpush.intent.MULTI_PROCESS
10-15 19:57:05.476: D/JIGUANG-JPush(9359): [JPushLocalNotificationCenter] add LocalNotification

设置30天后推送adb日志

10-15 19:59:17.508: D/JIGUANG-JPush(9359): [JPushDataAction] Action - onActionRun
10-15 19:59:17.508: D/JIGUANG-JPush(9359): [PushServiceCore] bundle:Bundle[{sdktype=JPUSH, action=org.qing.jpush.intent.MULTI_PROCESS, multi_type=6, local_notification=cn.jpush.android.data.JPushLocalNotification@1}]
10-15 19:59:17.508: D/JIGUANG-JPush(9359): [PushServiceCore] Action - handleServiceAction - action:org.qing.jpush.intent.MULTI_PROCESS
10-15 19:59:17.508: D/JIGUANG-JPush(9359): [JPushLocalNotificationCenter] add LocalNotification
10-15 19:59:17.584: D/JIGUANG-JCore(9359): [PushReceiver] onReceive - cn.jpush.android.intent.NOTIFICATION_RECEIVED_PROXY
10-15 19:59:17.588: D/JIGUANG-JPush(9359): [PushReceiverCore] onReceive - cn.jpush.android.intent.NOTIFICATION_RECEIVED_PROXY
10-15 19:59:17.604: D/JIGUANG-JPush(9359): [NotificationHelper] running flag:false
10-15 19:59:17.604: D/JIGUANG-JPush(9359): [NotificationHelper] notification intent component=ComponentInfo{org.qing.jpush/cn.jpush.android.service.PushReceiver}
10-15 19:59:17.604: I/NotificationManagerService(502): send statusbar msg to player:jpush-unity3d-demo:推送内容
10-15 19:59:17.612: D/dalvikvm(780): GC_CONCURRENT freed 1678K, 49% free 11005K/21272K, paused 2ms+0ms, total 7ms
10-15 19:59:17.612: E/WVMExtractor(155): Failed to open libwvm.so
10-15 19:59:17.620: D/JIGUANG-JPush(9359): [NotificationHelper] Send push received broadcast to developer defined receiver
10-15 19:59:17.620: I/JPushReceiver(9359): GameObject: Canvas

导出工程有一个#define UNITY_USES_REMOTE_NOTIFICATIONS的坑

我的Unity版本2017
在导出Xcode项目之后,必须将
Preprocessor.h 文件中

#define UNITY_USES_REMOTE_NOTIFICATIONS 0
更改为
#define UNITY_USES_REMOTE_NOTIFICATIONS 1

否则

didReceiveRemoteNotification
didRegisterForRemoteNotificationsWithDeviceToken
didReceiveRemoteNotification

都将无法使用

请在说明文档中写明这个修改

Unity 2019.4 iOS从Xcode编译到手机报错,_dns_parse_resource_record

已经添加了libresolv.tbd
并且项目在 Unity2018.4 中可以正常使用,升级到2019 JPush编译错误。
: "_dns_parse_resource_record", referenced from:

: -[JCORESRVResolver processRecord:length:] in jcore-ios-2.1.8.a(JCORESRVResolver.o)

: "_dns_free_resource_record", referenced from:

: -[JCORESRVResolver processRecord:length:] in jcore-ios-2.1.8.a(JCORESRVResolver.o)

SetAlias返回错误码6002

我刚开始接入这个插件,Unity版本是2018.2.7f1。在网页后台已经设好了Android和iOS的推送设置。下面是用iOS的包在iphoneX上的结果

参照文档,我先调用了JPushBinding.Init(gameObject.name);,然后JPushBinding.SetAlias(1, "abc")。等了一会回调也调到了,但参数的json内容是{"sequence":1,"code":6002}。根据文档,重试了几次,还是这个结果。

如果我尝试发送全员广播推送,会报告错误“没有满足条件的推送目标”。

猜测可能是Init时就失败了。有什么建议吗?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.