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
Is there an option to ignore the launchURL? #105
Comments
@ccstorch @avishayil There isn't a way to disable the behavior for launch URL in the app. In your case you will need to send 2 separate notifications. One to just your Chrome extension with a launch URL set and another to your mobile app. |
No problem, thanks for the help @jkasten2! |
Swizzling the #import <RCTOneSignal/RCTOneSignal.h>
#import <objc/runtime.h>
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Don't do this unless in dire yolo situations
SwizzleClassMethod(NSClassFromString(@"OneSignalHelper"), @selector(displayWebView:), [AppDelegate class], @selector(displayWebView:));
NSString *oneSignalAPIID = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"ONE_SIGNAL_API_ID"];
self.oneSignal = [[RCTOneSignal alloc] initWithLaunchOptions:launchOptions appId:oneSignalAPIID];
return YES;
}
+ (void) displayWebView:(NSURL*)url {
NSLog(@"This is dumb");
}
void SwizzleClassMethod(Class cOriginal, SEL orig, Class cNew, SEL new) {
Method origMethod = class_getClassMethod(cOriginal, orig);
Method newMethod = class_getClassMethod(cNew, new);
cOriginal = object_getClass((id)cOriginal);
cNew = object_getClass((id)cNew);
if(class_addMethod(cOriginal, orig, method_getImplementation(newMethod), method_getTypeEncoding(newMethod))) {
class_replaceMethod(cNew, new, method_getImplementation(origMethod), method_getTypeEncoding(origMethod));
} else {
method_exchangeImplementations(origMethod, newMethod);
}
}
@end |
Hello!
I already setup everything and the notifications are working perfectly.
When I send a normal message without url and press on the notification, the mobile app is launched, which is what I want.
But the one signal account that it is sending the notification is also used on a chrome extension, so there is an url for a website configured on the params of the notification. So when the mobile receive this notification, it is using the url for the website, and is opening a browser and not the mobile app.
Is there any way to ignore the url?
Or maybe stop the normal behavior and manually open the mobile app?
Or I am doing something wrong to get this result?
Thanks for the help.
The text was updated successfully, but these errors were encountered: