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

iOS : In AppDelegate+FirebasePlugin.m add the variable tap in the method didReceiveRemoteNotification() #1104

Open
wants to merge 764 commits into
base: master
Choose a base branch
from

Conversation

papattes
Copy link

TODO

to make the variable tap available when receiving a notification from the background, replace :

//Tells the app that a remote notification arrived that indicates there is data to be fetched.
// Called when a message arrives in the foreground and remote notifications permission has been granted
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
    fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {

    @try{
        NSDictionary *mutableUserInfo = [userInfo mutableCopy];
        NSDictionary* aps = [mutableUserInfo objectForKey:@"aps"];
        if([aps objectForKey:@"alert"] != nil){
            [mutableUserInfo setValue:@"notification" forKey:@"messageType"];
        }else{
            [mutableUserInfo setValue:@"data" forKey:@"messageType"];
        }

        NSLog(@"didReceiveRemoteNotification: %@", mutableUserInfo);
        
        completionHandler(UIBackgroundFetchResultNewData);
        [self processMessageForForegroundNotification:mutableUserInfo];
        [FirebasePlugin.firebasePlugin sendNotification:mutableUserInfo];
    }@catch (NSException *exception) {
        [FirebasePlugin.firebasePlugin handlePluginExceptionWithoutContext:exception];
    }
}

By

//Tells the app that a remote notification arrived that indicates there is data to be fetched.
// Called when a message arrives in the foreground and remote notifications permission has been granted
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
    fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {

    @try{
        NSDictionary *mutableUserInfo = [userInfo mutableCopy];
        NSDictionary* aps = [mutableUserInfo objectForKey:@"aps"];
        if([aps objectForKey:@"alert"] != nil){
            [mutableUserInfo setValue:@"notification" forKey:@"messageType"];
        }else{
            [mutableUserInfo setValue:@"data" forKey:@"messageType"];
        }

        NSString* tap;
        if([self.applicationInBackground isEqual:[NSNumber numberWithBool:YES]]){
            tap = @"background";
        }else{
            tap = @"foreground";
        }
        [mutableUserInfo setValue:tap forKey:@"tap"];
        if([mutableUserInfo objectForKey:@"messageType"] == nil){
            [mutableUserInfo setValue:@"notification" forKey:@"messageType"];
        }

        NSLog(@"didReceiveRemoteNotification: %@", mutableUserInfo);
        
        completionHandler(UIBackgroundFetchResultNewData);
        [self processMessageForForegroundNotification:mutableUserInfo];
        [FirebasePlugin.firebasePlugin sendNotification:mutableUserInfo];
    }@catch (NSException *exception) {
        [FirebasePlugin.firebasePlugin handlePluginExceptionWithoutContext:exception];
    }
}

dpa99c added a commit to dpa99c/cordova-plugin-firebasex that referenced this pull request Aug 30, 2019
…le app is running in background.

* Based on arnesson#1104
* Resolves #96
@dpa99c dpa99c force-pushed the master branch 2 times, most recently from 21bc600 to ad9ec9d Compare September 30, 2020 12:59
ollm and others added 25 commits October 17, 2021 12:04
…uesting necessary permissions, adding the entitlement and adding documentation.
…ions

(iOS) Feature: add support for iOS critical alerts. This includes req…
(Android) Add option to configure the notification channel usage and …
…dk-31

(Android) Feat: add android:exported element
… variable.

Bump Android Gradle build tool versions.
Supersedes #696.
Resolves #695.
fix setUserProperty parameters in README.md
(Android) Fix/Feat: Improved notification image support
(Android) Feat: Support html attributes in body notifications
Support Firebase Authentication emulator
Add missing type for authenticateUserWithEmailAndPassword
Use OAuthProvider when available during linkUserWithCredential
Fix: correct return type of a method
Feature #572: Implement authorization request for critical alerts on iOS
- add actionCodeSettings as a command argument
- use parameters for the actionCodeSettings values in both ios and android
- update readme.md
TheNotorius0 and others added 13 commits October 26, 2024 16:14
Removed unnecessary "rawNonce" from FirebasePlugin.m
Hold notifications when the app is in background and and call the app callback once back in foreground.
…ook script, so local cocoapods repo is refreshed from remote, ensuring latest versions are available locally
Handle notification callback in the background
…RY plugin variable to override default behaviour and attempt to immediately deliver the payload of a message received while the app is in the background or inactive
…lugin variable to override default behaviour and attempt to immediately deliver the payload of a message received while the app is in the background or inactive
…e so it aligns with other component versions
…set if plugin variable IOS_USE_PRECOMPILED_FIRESTORE_POD is set to true
dpa99c and others added 16 commits November 8, 2024 15:25
feat(ios): prepare for cordova-ios 8 support - corrected app name
…ents. Gracefully fail if they are missing.
…e non-standard versions such as 8.0.0-beta.1
…restore pod version if IOS_USE_PRECOMPILED_FIRESTORE_POD=true
(cordova): fix invalid cordova hook interface use, fix #908
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

Successfully merging this pull request may close these issues.