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 781 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
dpa99c and others added 16 commits January 26, 2022 16:12
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
Fix an error getting the providerId that could cause getCurrentUser to fail on android
…l-verification

include actionCodeSettings in the sendUserEmailVerification function
BREAKING CHANGES - see CHANGELOG.md for details
BREAKING CHANGES - see CHANGELOG.md for details
Dave Alden and others added 30 commits November 9, 2024 14:45
…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
feat(ios): Turn on debug view for debug builds
…ag-manager

fix: Integration with GoogleTagManager
remove unused cordova-ios import that breaks projects without ios platform
Current exception logging throws NPE. Change to Crashlytics log to properly handle these exceptions
…dential auth/credential-already-in-use error
Handle notification exceptions
Access to FIRAuthErrorUserInfoUpdatedCredentialKey on linkUserWithCredential auth/credential-already-in-use error
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.