尝试整合one signal到我的反应本机应用程序中。
我遵循了文档https://documentation.onesignal.com/docs/react-native-sdk-setup中提到的所有说明 。
应用程序的构建成功,但在将应用程序附加到设备时出现错误。
Xcode 打开一个标题为 的线程dyld__abort_with_payload。
当我调查错误时。错误看起来像这样。
dyld: Library not loaded: @rpath/OneSignal.framework/OneSignal
Referenced from: /Users/sakshyaarora/Library/Developer/CoreSimulator/Devices/357B8E50-B8A6-4F9D-AE06-40DD8004351E/data/Containers/Bundle/Application/242BEDF6-76CD-4516-BF58-C86C43F6C4D4/Test.app/Test
Reason: image not found
dyld: launch, loading dependent libraries
DYLD_SHARED_CACHE_DIR=/Users/sakshyaarora/Library/Developer/CoreSimulator/Caches/dyld/20F71/com.apple.CoreSimulator.SimRuntime.iOS-14-5.18E182
DYLD_ROOT_PATH=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot
DYLD_LIBRARY_PATH=/Users/sakshyaarora/Library/Developer/Xcode/DerivedData/Test-djshtsdmeowdbaebqzmujevyppyj/Build/Products/Debug-iphonesimulator:/Users/sakshyaarora/Sites/projects/Test/Builds/iOS/build/Debug/-iphonesimulator:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/system/introspection
DYLD_INSERT_LIBRARIES=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libBacktraceRecording.dylib:/Applica
Run Code Online (Sandbox Code Playgroud)
我尝试这个已经好几个小时了。任何帮助,将不胜感激。
提前致谢。:)
我开发了一个React Native应用程序,当该应用程序处于活动状态时,每次收到来自OneSignal的推送通知时,该应用程序都会崩溃。
错误是java.lang.NoSuchMethodError: No static method zzc。
如果我在应用程序处于后台运行状态时收到通知,则没有问题。
这是我的build.gradle文件:
buildscript {
ext {
googlePlayServicesLocationVersion = "17.0.0"
buildToolsVersion = "28.0.3"
minSdkVersion = 21
compileSdkVersion = 28
targetSdkVersion = 28
supportLibVersion = "28.0.0"
appCompatVersion = "1.0.2"
}
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
}
}
allprojects {
repositories {
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == 'com.google.android.gms') {
details.useVersion '17.0.0'
}
if (requested.group == 'com.google.firebase') {
details.useVersion '17.0.0'
}
} …Run Code Online (Sandbox Code Playgroud) 当用户通过单击通知打开应用程序时,我尝试导航到底部选项卡导航器上的某个屏幕。
查看官方文档Navigating without the navigation prop,我的主导航器设置如下:
import {navigationRef, isReadyRef} from './root';
const MainNav = _ => {
if (isLoading) {
return isFirstTime ? (<OnBoarding />) : (<SplashScreen />);
}
return (
<NavigationContainer
ref={navigationRef}
onReady={() => {isReadyRef.current = true}}>
{!token ? <AuthNav /> : <AppNav />}
</NavigationContainer>
);
}
Run Code Online (Sandbox Code Playgroud)
我的root.js如下:
import * as React from 'react';
export const isReadyRef = React.createRef();
export const navigationRef = React.createRef();
export function navigate(name, params) {
if (isReadyRef.current && navigationRef.current) {
// Perform navigation …Run Code Online (Sandbox Code Playgroud) react-native react-redux react-navigation react-native-onesignal
我按照本指南在我的反应本机应用程序中设置 OneSignal 后台通知:https ://documentation.onesignal.com/docs/rn-android-native-module-setup-for-notification-service-extension#ios-notification-服务扩展模块
当我通过 Xcode 将应用程序直接安装到我的设备时,后台通知按预期工作。但是当我存档构建并从 TestFlight 安装它时,后台通知不起作用。除非emitNotificationEvent我添加的事件没有被触发,即使收到了推送通知。
当我在 Xcode 中跟踪存档构建的问题(使用设备控制台)时,_instance注意到NotificationExtensionModule.m. 有人遇到过类似的问题或知道可能是什么原因吗?
笔记
添加代码片段以进一步了解我的问题:
AppDelegate.h
#import <Foundation/Foundation.h>
#import <React/RCTBridgeDelegate.h>
#import <UIKit/UIKit.h>
#import <UserNotifications/UserNotifications.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate,RCTBridgeDelegate,UNUserNotificationCenterDelegate>
@property (nonatomic, strong) UIWindow *window;
@end
Run Code Online (Sandbox Code Playgroud)
AppDelegate.m
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
{
//access NotificationServiceExtensionModule emitNotificationEvent method
[NotificationServiceExtensionModule.sharedInstance emitNotificationEvent:userInfo ];
completionHandler(UIBackgroundFetchResultNoData);
}
Run Code Online (Sandbox Code Playgroud)
通知服务扩展模块.h
#import <foundation/Foundation.h>
// NotificationServiceExtensionModule.h
#import <React/RCTBridgeModule.h>
#import <React/RCTEventEmitter.h>
@interface NotificationServiceExtensionModule : …Run Code Online (Sandbox Code Playgroud) ios testflight react-native onesignal react-native-onesignal
我正在使用 Onesignal 进行推送通知,但陷入错误并且很多天都找不到解决方案。
OneSignal SDK配置:
世博 SDK 设置:
展会安装 onesignal-expo-plugin
纱线添加反应本机信号
{ "plugins": [ "onesignal-expo-plugin", { "mode": "development", }] }
从 'react-native-onesignal' 导入 OneSignal;
useEffect(() => { OneSignal.setAppId("在此处粘贴复制的 APP ID"); }, []);
世博预建
但出现错误
TypeError: Cannot read property 'smallIcons' of undefinedn at withSmallIcons (\node_modules\onesignal-expo-plugin\build\onesignal\withOneSignalAndroid.js)
Run Code Online (Sandbox Code Playgroud)
现在与此反应本机项目相关的所有控制台命令都会出现此错误。
我通过以下文档配置了 Onesignal https://documentation.onesignal.com/docs/react-native-expo-sdk-setup
react-native onesignal firebase-cloud-messaging expo react-native-onesignal