Coder Social home page Coder Social logo

Comments (10)

stevenxyj avatar stevenxyj commented on August 29, 2024 2

找到原因了,

  • (void)xgPushUserNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler

  • (void)xgPushUserNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler

两个方法,放在 AppDelegate.m 不会被响应,放在 XGPushManager.m 可以正常被执行
Jeepeng 可以测试一下,是不是这样,目前我这样处理可以满足应用,等待 Jeepeng 验证和更适当的处理方法。

#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
- (void)xgPushUserNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler {
	NSLog(@"[XGPush] click notification");
	
	NSDictionary *userInfo = response.notification.request.content.userInfo;
	NSLog(@"[XGPush] userinfo %@", userInfo);

	UIApplication *applicaiton = [UIApplication sharedApplication];
	UIApplicationState state = applicaiton.applicationState;
	BOOL isClicked = (state != UIApplicationStateActive);
	NSMutableDictionary *remoteNotification = [NSMutableDictionary dictionaryWithDictionary:userInfo];
	if(isClicked) {
	  remoteNotification[@"clicked"] = @YES;
	  remoteNotification[@"background"] = @YES;
	}
	
	[[XGPush defaultManager] reportXGNotificationInfo:remoteNotification];
    [XGPushManager didReceiveRemoteNotification:remoteNotification];

	completionHandler();
}

- (void)xgPushUserNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler {
	[[XGPush defaultManager] reportXGNotificationInfo:notification.request.content.userInfo];
	completionHandler(UNNotificationPresentationOptionBadge | UNNotificationPresentationOptionSound | UNNotificationPresentationOptionAlert);
}
#endif

from react-native-xinge-push.

stevenxyj avatar stevenxyj commented on August 29, 2024

还发现另一个 bug,
ios 9 以下版本点击调用 notification 事件,但 notification.clicked 没有值 ,android 上有值

我将 didReceiveRemoteNotification 方法中代码做了如下修改,即可

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
  NSLog(@"[XGPush] receive slient notification");
  NSLog(@"[XGPush] userinfo %@", userInfo);
  
  UIApplicationState state = [application applicationState];
  BOOL isClicked = (state != UIApplicationStateActive);
  NSMutableDictionary *remoteNotification = [NSMutableDictionary dictionaryWithDictionary:userInfo];
  if(isClicked) {
    remoteNotification[@"clicked"] = @YES;
    remoteNotification[@"background"] = @YES;
  }
  
  [[XGPush defaultManager] reportXGNotificationInfo:remoteNotification];
  [XGPushManager didReceiveRemoteNotification:remoteNotification fetchCompletionHandler:completionHandler];
}

from react-native-xinge-push.

wanxsb avatar wanxsb commented on August 29, 2024

@stevenxyj 你改了什么内容,没有看懂?

from react-native-xinge-push.

wanxsb avatar wanxsb commented on August 29, 2024

@Jeepeng @stevenxyj 实际验证下来,APP无论是在前台还是后台,在点击APP时都没有调用回调函数,我重构了一下,同时将静默消息该成了透传,看一下是否可以
https://github.com/wanxsb/react-native-xinge-push
已经提Pull Request了
wechatimg241
wechatimg242
wechatimg243
wechatimg244

from react-native-xinge-push.

charmtiger avatar charmtiger commented on August 29, 2024

感谢贡献

from react-native-xinge-push.

stackia avatar stackia commented on August 29, 2024

同样,0.7存在这个问题。

from react-native-xinge-push.

musicode avatar musicode commented on August 29, 2024

@Jeepeng 这个问题方便在主版本修复一下嘛

from react-native-xinge-push.

musicode avatar musicode commented on August 29, 2024

@Jeepeng 拜托拜托,我感觉每个人都会碰到这个问题,安卓是好的,iOS 不行啊

from react-native-xinge-push.

Allen-su avatar Allen-su commented on August 29, 2024

@wanxsb 我使用了你的代码,但是在前台的时候还是不能收到通知,你有遇到这种状况吗,是需要什么配置么,或者有没有完整的配置项可以参考么

from react-native-xinge-push.

musicode avatar musicode commented on August 29, 2024

@wanxsb 作者貌似不打算维护这个库了,你能把你的分支升级到信鸽的最新版本吗?

from react-native-xinge-push.

Related Issues (20)

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.