Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use of unresolved identifier 'RCTOneSignalExtensionService' #530

Closed
gustavomanolo opened this issue May 23, 2018 · 13 comments
Closed

Use of unresolved identifier 'RCTOneSignalExtensionService' #530

gustavomanolo opened this issue May 23, 2018 · 13 comments

Comments

@gustavomanolo
Copy link

Description:
I followed instructions from https://documentation.onesignal.com/v5.0/docs/react-native-sdk-setup and i'm getting the following error in the NotificationService.swift file:

Use of unresolved identifier 'RCTOneSignalExtensionService'

In the following lines:
RCTOneSignalExtensionService.didReceive(self.receivedRequest, with: self.bestAttemptContent);

RCTOneSignalExtensionService.serviceExtensionTimeWillExpireRequest(self.receivedRequest, with: self.bestAttemptContent);

(your description here)

Environment

React native version
react-native-cli: 2.0.1
react-native: 0.55.3

OneSignal React-Native SDK version
3.2.4

How did you add the SDK to your project (eg. npm)
Through npm
npm install --save react-native-onesignal
react-native link

Steps to Reproduce Issue:

`import UserNotifications

class NotificationService: UNNotificationServiceExtension {

var contentHandler: ((UNNotificationContent) -> Void)?
var bestAttemptContent: UNMutableNotificationContent?
var receivedRequest : UNNotificationRequest!;

override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
    self.contentHandler = contentHandler
    bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)
    self.receivedRequest = request;
    
    RCTOneSignalExtensionService.didReceive(self.receivedRequest, with: self.bestAttemptContent);
    
    if let bestAttemptContent = bestAttemptContent {
        contentHandler(bestAttemptContent)
    }
}

override func serviceExtensionTimeWillExpire() {
    // Called just before the extension will be terminated by the system.
    // Use this as an opportunity to deliver your "best attempt" at modified content, otherwise the original push payload will be used.
    RCTOneSignalExtensionService.serviceExtensionTimeWillExpireRequest(self.receivedRequest, with: self.bestAttemptContent);
    
    if let contentHandler = contentHandler, let bestAttemptContent =  bestAttemptContent {
        contentHandler(bestAttemptContent)
    }
}

}`

@gustavomanolo
Copy link
Author

gustavomanolo commented May 23, 2018

Also when i open the app i'm getting the following error when i try to init OneSignal:

Cannot read property 'initWithAppId' of undefined

@Nightsd01
Copy link
Contributor

@gustavomanolo Are you sure you created the Objective-C bridging header and imported RCTOneSignal into it...?

@Nightsd01
Copy link
Contributor

Closing due to no response...

@sahil-innostax
Copy link

Hi @Nightsd01 I am facing the same issue.i have created the Objective-C bridging header and imported RCTOneSignal

It looks like this

#ifndef Objective_CBridgingHeader_h
#define Objective_CBridgingHeader_h
#import "RCTOneSignalExtensionService.h"

#endif 

but still i am getting the same error

@yarism
Copy link

yarism commented Jun 16, 2018

Having the same issue... tried switching to objective-c to see if that would solve it but only getting

fatal error: 'RCTOneSignalExtensionService.h' file not found

@sksahil030 did you find a solution?

@jephtta
Copy link

jephtta commented Jun 25, 2018

Any updates on this? Just like @yarism, I have the same issue even though i have created the header file.

@sahil-innostax
Copy link

@yarism No, i couldn't find any solution for it

@nord2ost
Copy link

nord2ost commented Jun 27, 2018

@yarism @sksahil030
I had the same problem. I've solvd it by targeting OneSignalNotificationService, selecting Build Settings, finding 'Objective-C Bridging Header' and adding path to the previously made Objective-C header file. Soemthing like "your project/OneSignalNotificationServiceExtension/Header.h"

@dutterbutter
Copy link

dutterbutter commented Jun 29, 2018

I know this issue is closed but I am experiencing the same issue within my NotificationService.swift in the OneSignalNotificationServiceExtension folder. Specifically the Use of unresolved identifier 'RCTOneSignalExtensionService' error.

I proceeded to create a header file within the same folder directory much like @sksahil030

#ifndef OneSignalNotificationServiceExtension_Swift_h
#define OneSignalNotificationServiceExtension_Swift_h
#import "RCTOneSignalExtensionService.h"

#endif /* OneSignalNotificationServiceExtension_Swift_h */

In the OneSignalNotificationService target > Build Settings. I have specified the following Objective-C Bridging Header path, as mentioned by @nord2ost

$(SRCROOT)/../node_modules/react-native-onesignal/ios/OneSignalNotificationServiceExtension/OneSignalNotificationServiceExtension-Swift.h

After running react-native run-ios the error message I am getting indicates it cannot find the NotificationServiceExtension-Swift.h file specified in the Objective-C Bridging Header path. I am sure that is the correct path to file.

Main questions: If creating the Objective-C Bridging Header and adding in #import "RCTOneSignalExtensionService.h" is the solution what is the correct way to implement?

How to resolve Use of unresolved identifier 'RCTOneSignalExtensionService' error.

Thanks.

@dutterbutter
Copy link

I must apologize, it was an incorrect path issue. The above steps of creating a header file and then specifying the path in the Objective-C Bridging Header path of the OneSignalNotificationService target was the solution for me. Thanks.

@vinceprofeta
Copy link

vinceprofeta commented Jul 24, 2018

For anyone having issues with this: clarifying @nord2ost

In the OneSignalNotificationService folder > Build Settings > Header Search Paths add $(SRCROOT)/../node_modules/react-native-onesignal/ios

Create a bridge header and name it whatever you want. and add
#import "RCTOneSignalExtensionService.h"
so it looks like

#ifndef YOUR_NAMED_HEADER
#define YOUR_NAMED_HEADER
#import "RCTOneSignalExtensionService.h"
#endif /* YOUR_NAMED_HEADER */

Go back into OneSignalNotificationService, selecting Build Settings, finding 'Objective-C Bridging Header' and add

$(SRCROOT)/OneSignalNotificationServiceExtension/YOUR_NAMED_HEADER.h

@kylethielk
Copy link

Thanks for the clear instructions @vinceprofeta, saved me a ton of time. Some of this stuff isn't immediately obvious for us with limited native iOS dev experience.

@simonemarinelli
Copy link

OneSignalNotificationServiceExtension target > Build Settings > Header Search Paths
Add $(SRCROOT)/../node_modules/react-native-onesignal/ios as recursive

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants