wonday / react-native-aliyun-push Goto Github PK
View Code? Open in Web Editor NEWA react native wrapper for aliyun push SDK
License: MIT License
A react native wrapper for aliyun push SDK
License: MIT License
请问有办法解决吗/?
你好,我在xcode9下出现如下警告
Main Thread Checker: UI API called on a background thread: -[UIApplication registerForRemoteNotifications]
我看这个插件ios的有一上来就通知用户开启通知功能,安卓的没有吗?
使用版本是v1.0.13,安卓无法接收到通知和消息。
在前几个版本android是可以接收到消息的。
在android中的MainApplication中register打印日志,返回的是绑定成功
在RN中获取到deviceId,然后用得到的deviceId到阿里的控制台查看设备,设备是在线的。在RN的debug模式中,打印账号绑定参数是成功的。
在IOS上能够通过阿里控制台的推送接收到。
在android上,通过两台华为机器测试,无法收到消息和通知,不知道是什么原因造成的。
IOS端缺少角标同步API~RT
在app内部推送通知和消息都能够通过监听获取到,但是通知栏没有反应。查看app的权限是有通知权限的,手机是nexus6p。
另外通知栏的小icon也都有设置。
但是,就是没有通知栏,请问有人遇到过这种情况吗?
现在如果程序运行在前台,收到消息会有弹窗,如何判断前台 只接收 不弹窗?
请问一下,我用阿里云网页控制台或者调用openApi来推送通知,手机上都会产生两条通知,是为什么呢?
打开应用的时候连续接收到,有没有办法?是我设置问题吗还是?
oppo手机,手机的通知打开了,收到通知后也能触发回调,AliyunPush.addListener(this.handleAliyunPushMessage);但是通知栏就是没有通知,不管app是杀死还是活跃状态,前台还是后台都不行。还有,进去看了下代码,是不是没有监听点击通知的回调方法啊?有的话是哪个呢。坐等作者告知,谢谢
升级到rn0.49 这个已经找不到了
ExceptionsManager.js:73 Exception '*** -[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[0]' was thrown while invoking getDeviceId on target AliyunPush with params (
49
)
callstack: (
0 CoreFoundation 0x000000010dbd71e6 __exceptionPreprocess + 294
1 libobjc.A.dylib 0x000000010c04d031 objc_exception_throw + 48
2 CoreFoundation 0x000000010dc170bc _CFThrowFormattedException + 194
3 CoreFoundation 0x000000010dae445d -[__NSPlaceholderArray initWithObjects:count:] + 237
4 CoreFoundation 0x000000010daeae24 +[NSArray arrayWithObjects:count:] + 52
5 TestApp 0x0000000109f5ac21 -[AliyunPushManager getDeviceId:] + 145
6 CoreFoundation 0x000000010db5accc __invoking___ + 140
7 CoreFoundation 0x000000010db5ab84 -[NSInvocation invoke] + 308
8 CoreFoundation 0x000000010db738d6 -[NSInvocation invokeWithTarget:] + 54
9 TestApp 0x0000000109c0d5ec -[RCTModuleMethod invokeWithBridge:module:arguments:] + 2796
10 TestApp 0x0000000109cc0d92 _ZN8facebook5reactL11invokeInnerEP9RCTBridgeP13RCTModuleDatajRKN5folly7dynamicE + 786
11 TestApp 0x0000000109cc08bf _ZZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEiENK3$_0clEv + 127
12 TestApp 0x0000000109cc0839 ___ZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEi_block_invoke + 25
13 libdispatch.dylib 0x00000001128b573b _dispatch_call_block_and_release + 12
14 libdispatch.dylib 0x00000001128b6779 _dispatch_client_callout + 8
15 libdispatch.dylib 0x00000001128be1b2 _dispatch_queue_serial_drain + 735
16 libdispatch.dylib 0x00000001128be9af _dispatch_queue_invoke + 321
17 libdispatch.dylib 0x00000001128bb16a _dispatch_queue_override_invoke + 477
18 libdispatch.dylib 0x00000001128c0cf8 _dispatch_root_queue_drain + 473
19 libdispatch.dylib 0x00000001128c0ac1 _dispatch_worker_thread3 + 119
20 libsystem_pthread.dylib 0x0000000112dd81ca _pthread_wqthread + 1387
21 libsystem_pthread.dylib 0x0000000112dd7c4d start_wqthread + 13
)
请问是什么原因?
react native: 0.54.4
aliyun-push: latest
如题
-[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[0]' was thrown while invoking getDeviceId on target AliyunPush with params (
49
)
[email protected]
好像原来使用1.0.9是好的,是不是ios sdk有什么问题
项目里明明已经有AliyunPushManager.h文件了,为什么我运行的时候还是报AliyunPushManager.h file not found的错?跪求
控制台发送通知后,手机接收,点击通知后闪退,提示错误:
[NSDate<0x389d9348> init]: cannot init a class object
应用打开或者应用退出,都会发生。
苹果4S
react-native: 0.54.4
aliyun-push: 1.0.11
这个组件中能不能加一个这样的方法?
iOS:
app退出后,收到通知,点击通知后app闪退
app未退出,收到通知,点击通知正常。
*** Terminating app due to uncaught exception 'RCTFatalException: Exception '*** -[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[0]' was thrown while invoking getDeviceId on target AliyunPush with params ( 5 ) callstack: ( 0 CoreFoundation 0x000000018396ada4 <redacted> + 252 1 libobjc.A.dylib 0x0000000182b245ec objc_exception_throw + 56 2 CoreFoundation 0x0000000183903750 _CFArgv + 0 3 CoreFoundation 0x0000000183836a18 <redacted> + 284 4 CoreFoundation 0x0000000183842c78 <redacted> + 52 5 Bytter 0x00000001029f9188 _ZN5folly6detail15str_to_integralIxEENS_8ExpectedIT_NS_14ConversionCodeEEEPNS_5RangeIPKcEE + 456504 6 CoreFoundation 0x0000000183972580 <redacted> + 144 7 CoreFoundation 0x0000000183851748 <redacted> + 284 8 CoreFoundation 0x0<…>
使用版本号
"react-native-aliyun-push": "1.0.11",
"react-native": "0.54.2",
已经替换了最新包中的libs
手机删除APP,重启手机,xcode clean,打包签名生成IPA,通过iFunbox安装到手机上,启动APP后提示“APP想给您发送通知”的alert提示框,这个时候app已经闪退。
允许通过推送后,再次点击APP,未进入到任何一个页面,直接闪退!
多次点启动APP闪退后,大约闪退8次之后,app启动正常
debug模式下能够正常接收推送信息。
补充:
我注释掉 AliyunPush.getDeviceId
方法体的内容,试了下是不会闪退,那是不是证明在回调方法中执行
AliyunPushNative.getDeviceId
这个方法是有问题的?
ios过审时没通过,原来是ios在初次安装应用时,在未选允许发送退知权限时,调用AliyunPush.getDeviceId 会报错
AliyunPush.getDeviceId(deviceId => {
console.log(AliyunPush DeviceId: ${deviceId}
)
})
iphone7
react-native: 0.55.4
aliyun-push: 1.0.11
import android.app.Application;
// 下面是被添加的代码
import org.wonday.aliyun.push.AliyunPushPackage;
import com.alibaba.sdk.android.push.CloudPushService;
import com.alibaba.sdk.android.push.CommonCallback;
import com.alibaba.sdk.android.push.noonesdk.PushServiceFactory;
import com.alibaba.sdk.android.push.register.HuaWeiRegister;
import com.alibaba.sdk.android.push.register.MiPushRegister;
// 添加结束
import com.facebook.react.ReactApplication;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;
import java.util.Arrays;
import java.util.List;
public class MainApplication extends Application implements ReactApplication {
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
@Override
public boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new AliyunPushPackage()
);
}
@Override
protected String getJSMainModuleName() {
return "index";
}
};
@Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}
@Override
public void onCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */ false);
//下面是添加的代码
this.initCloudChannel();
//添加结束
}
// 下面是添加的代码
/**
* 初始化阿里云推送通道
* @param applicationContext
*/
private void initCloudChannel() {
PushServiceFactory.init(this.getApplicationContext());
CloudPushService pushService = PushServiceFactory.getCloudPushService();
//pushService.setNotificationSmallIcon(R.mipmap.ic_launcher_s);//设置通知栏小图标, 需要自行添加
pushService.register(this.getApplicationContext(), "24956511", "c18e999edd0a8c6994ca42e69f931e34", new CommonCallback() {
@Override
public void onSuccess(String responnse) {
// success
}
@Override
public void onFailed(String code, String message) {
// failed
}
});
// 注册方法会自动判断是否支持小米系统推送,如不支持会跳过注册。
//MiPushRegister.register(this.getApplicationContext(), "小米AppID", "小米AppKey");
// 注册方法会自动判断是否支持华为系统推送,如不支持会跳过注册。
//HuaWeiRegister.register(this.getApplicationContext());
}
}
apply plugin: "com.android.application"
import com.android.build.OutputFile
/**
* The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
* and bundleReleaseJsAndAssets).
* These basically call `react-native bundle` with the correct arguments during the Android build
* cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
* bundle directly from the development server. Below you can see all the possible configurations
* and their defaults. If you decide to add a configuration block, make sure to add it before the
* `apply from: "../../node_modules/react-native/react.gradle"` line.
*
* project.ext.react = [
* // the name of the generated asset file containing your JS bundle
* bundleAssetName: "index.android.bundle",
*
* // the entry file for bundle generation
* entryFile: "index.android.js",
*
* // whether to bundle JS and assets in debug mode
* bundleInDebug: false,
*
* // whether to bundle JS and assets in release mode
* bundleInRelease: true,
*
* // whether to bundle JS and assets in another build variant (if configured).
* // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
* // The configuration property can be in the following formats
* // 'bundleIn${productFlavor}${buildType}'
* // 'bundleIn${buildType}'
* // bundleInFreeDebug: true,
* // bundleInPaidRelease: true,
* // bundleInBeta: true,
*
* // whether to disable dev mode in custom build variants (by default only disabled in release)
* // for example: to disable dev mode in the staging build type (if configured)
* devDisabledInStaging: true,
* // The configuration property can be in the following formats
* // 'devDisabledIn${productFlavor}${buildType}'
* // 'devDisabledIn${buildType}'
*
* // the root of your project, i.e. where "package.json" lives
* root: "../../",
*
* // where to put the JS bundle asset in debug mode
* jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
*
* // where to put the JS bundle asset in release mode
* jsBundleDirRelease: "$buildDir/intermediates/assets/release",
*
* // where to put drawable resources / React Native assets, e.g. the ones you use via
* // require('./image.png')), in debug mode
* resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
*
* // where to put drawable resources / React Native assets, e.g. the ones you use via
* // require('./image.png')), in release mode
* resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
*
* // by default the gradle tasks are skipped if none of the JS files or assets change; this means
* // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
* // date; if you have any other folders that you want to ignore for performance reasons (gradle
* // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
* // for example, you might want to remove it from here.
* inputExcludes: ["android/**", "ios/**"],
*
* // override which node gets called and with what additional arguments
* nodeExecutableAndArgs: ["node"],
*
* // supply additional arguments to the packager
* extraPackagerArgs: []
* ]
*/
project.ext.react = [
entryFile: "index.js"
]
apply from: "../../node_modules/react-native/react.gradle"
/**
* Set this to true to create two separate APKs instead of one:
* - An APK that only works on ARM devices
* - An APK that only works on x86 devices
* The advantage is the size of the APK is reduced by about 4MB.
* Upload all the APKs to the Play Store and people will download
* the correct one based on the CPU architecture of their device.
*/
def enableSeparateBuildPerCPUArchitecture = false
/**
* Run Proguard to shrink the Java bytecode in release builds.
*/
def enableProguardInReleaseBuilds = false
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.pushdemo"
minSdkVersion 16
targetSdkVersion 22
versionCode 1
versionName "1.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86"
}
}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
def versionCodes = ["armeabi-v7a":1, "x86":2]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
}
}
}
dependencies {
compile project(':react-native-aliyun-push')
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:23.0.1"
compile "com.facebook.react:react-native:+" // From node_modules
}
// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}
rootProject.name = 'pushdemo'
include ':react-native-aliyun-push'
project(':react-native-aliyun-push').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-aliyun-push/android')
include ':app'
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
maven {
url "http://maven.aliyun.com/nexus/content/repositories/releases/"
}
flatDir {
dirs project(':react-native-aliyun-push').file('libs')
}
}
}
Thread 12 name: Dispatch queue: com.facebook.react.AliyunPushQueue
Thread 12 Crashed:
0 libsystem_kernel.dylib 0x0000000183ec12e0 0x183e9f000 + 140000
1 libsystem_pthread.dylib 0x0000000184062288 0x18405f000 + 12936
2 libsystem_c.dylib 0x0000000183e2fd0c 0x183dcd000 + 404748
3 libc++abi.dylib 0x00000001835ca2c8 0x1835c9000 + 4808
4 libc++abi.dylib 0x00000001835ca470 0x1835c9000 + 5232
5 libobjc.A.dylib 0x00000001835f48d4 0x1835ec000 + 35028
6 dzcdriver 0x0000000100281e50 0x1000a4000 + 1957456
7 libc++abi.dylib 0x00000001835e437c 0x1835c9000 + 111484
8 libc++abi.dylib 0x00000001835e3ccc 0x1835c9000 + 109772
9 libobjc.A.dylib 0x00000001835f4720 0x1835ec000 + 34592
10 dzcdriver 0x0000000100120f60 0x1000a4000 + 511840
11 dzcdriver 0x0000000100176650 0x1000a4000 + 861776
12 dzcdriver 0x00000001001761c8 0x1000a4000 + 860616
13 libdispatch.dylib 0x0000000183d2caa0 0x183d2b000 + 6816
14 libdispatch.dylib 0x0000000183d2ca60 0x183d2b000 + 6752
15 libdispatch.dylib 0x0000000183d369b4 0x183d2b000 + 47540
16 libdispatch.dylib 0x0000000183d372fc 0x183d2b000 + 49916
17 libdispatch.dylib 0x0000000183d37cc8 0x183d2b000 + 52424
18 libdispatch.dylib 0x0000000183d40098 0x183d2b000 + 86168
19 libsystem_pthread.dylib 0x000000018405fe70 0x18405f000 + 3696
20 libsystem_pthread.dylib 0x000000018405fb08 0x18405f000 + 2824
请问这是什么问题?
reactnative get deviceToken???
错误代码
pushService.setNotificationSmallIcon(R.mipmap.ic_launcher_s);//设置通知栏小图标, 需要自行添加
这个报错,是我需要自己设置什么吗?
@wonday ;
第三方的模块我按照你的方法拖拽,并打勾了,但是包这个错误‘ramework not found UTDID’
在安卓端信息接收成功后闪退
按照说明一步一步操作的,但是最后真机调试的时候老是报错,这是什么原因?
Undefined symbols for architecture arm64: "_OBJC_CLASS_$_AliyunPushManager", referenced from: objc-class-ref in AppDelegate.o ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation)
请问阿里云推送支持安卓8.0吗
JS 通过 addListener
在代码层可以拿到推送消息.
我希望手机可以提供系统级别的 notification
是不是需要在下面代码的 success 中处理一些东西
pushService.register(this.getApplicationContext(), "xxx", "xxx", new CommonCallback() {
@Override
public void onSuccess(String responnse) {
// success
}
@Override
public void onFailed(String code, String message) {
// failed
}
});
调用getDeviceId获取到的deviceId是空的,是什么原因呢?
AliyunPush.getDeviceId((deviceId) => {
console.log(deviceId);
});
(void)onMessageReceived:(NSNotification *)notification
{
DLog(@"onMessageReceived.");
NSMutableDictionary *notificationDict = [notification object];
// 取得通知自定义字段内容
notificationDict[@"extras"] = [notification userInfo];//这里会报错
// 类型 “notification” or "message"
notificationDict[@"type"] = ALIYUN_PUSH_TYPE_MESSAGE;//这里会报错
[self sendEventToJs:notificationDict];
}
(void)sendEventToJs:(NSMutableDictionary*)notification
{
DLog(@"sendEventToJs:");
for (NSString *key in notification) {//这里会报错
DLog(@"key: %@ value: %@", key, notification[key]);
}
[self sendEventWithName:@"aliyunPushReceived" body:notification];
}
注释上面三处之后,不报错了,但是推送消息的时候js没有获取到内容,推送通知的时候没有反应
有没有什么替代方法?
在IOS真机环境下,后台接收通知如何获取到参数?在android参数的回调方法可以正常获取到通知的数据。在IOS下后台怎么才能在react native中获取到通知的数值?
还有一点就是我的OpenAPI是使用 iOSBadgeAutoIncrement做自增长。
需求是进入到app。1、点通知进入,需要在app获取通知的信息,然后跳转到指定页面。badge减一,2、点击app进入,清空所有的badge。。。
Android 平台 app 不在前台
@Override public void onHostPause() { //小米特殊处理, 处于后台时更新角标, 否则会被系统清除,看不到 if (MIUIUtils.isMIUI()) { Log.d(ReactConstants.TAG, "onHostPause:setBadgeNumber for xiaomi"); //MIUIUtils.setBadgeNumber(this.mRAC, getCurrentActivity().getClass(), badgeNumber); } }
@Override public void onHostDestroy() { //小米特殊处理, 处于后台时更新角标, 否则会被系统清除,看不到 if (MIUIUtils.isMIUI()) { Log.d(ReactConstants.TAG, "onHostDestroy:setBadgeNumber for xiaomi"); //MIUIUtils.setBadgeNumber(this.mRAC, getCurrentActivity().getClass(), badgeNumber); } }
你这段代码会让小米,一直显示一个“0条未读消息”的通知
get deviceToken???
ios的事件名是:“open“
android的事件名是:”opened”
改正一下
这个模块有在用的案例么?建个群交流一下呢。谢谢!
升级到1.0.9后,编译能通过,但是app启动闪退
V/fb-UnpackingSoSource: not releasing dso store lock for /data/user/0/com.elinter.app.powerview/lib-main (syncer thread started) I/SecurityBoxService: Aliyun I/art: Rejecting re-init on previously-failed class java.lang.Class<com.alibaba.sdk.android.push.impl.k> I/art: Rejecting re-init on previously-failed class java.lang.Class<com.alibaba.sdk.android.push.impl.k> I/MPS:CloudPushService: [AMS]Initialize Mobile Push service... W/AppMonitor: load ut_c_api.so failed I/art: Rejecting re-init on previously-failed class java.lang.Class<com.alibaba.sdk.android.push.impl.k> D/AndroidRuntime: Shutting down VM E/AndroidRuntime: FATAL EXCEPTION: main Process: com.elinter.app.powerview, PID: 3384 java.lang.NoClassDefFoundError: com.alibaba.sdk.android.push.impl.k at com.alibaba.sdk.android.push.impl.j.a(Unknown Source) at com.alibaba.sdk.android.push.noonesdk.PushServiceFactory.init(Unknown Source) at com.elinter.app.powerview.MainApplication.initCloudChannel(MainApplication.java:86) at com.elinter.app.powerview.MainApplication.onCreate(MainApplication.java:76) at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1015) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4834) at android.app.ActivityThread.access$1600(ActivityThread.java:168) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1440) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:150) at android.app.ActivityThread.main(ActivityThread.java:5659) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:822) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:712)
如题,在杀掉app之后,小米手机是否还可以收到推送的通知?
显示_OBJC_METACLASS_ link错误,好像是链接了两次,把alipaysdk删去就好了,想问一下有解决办法吗?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.