If I have an app that sends emails or sms messages to a users friends from within the app how can I check to make sure the message has gone through and sent successfully, or wether or not bad service got in the way of the message successfully sending and what not or can this not be done?
To see the result of sending an email from your app you should implement the delegate method mailComposeController:didFinishWithResult:result:error
- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
{
if (result == MFMailComposeResultSent) {
// email was sent successfully
} else if (result == MFMailComposeResultFailed) {
// email failed to send
NSLog(#"mail send error: %#", [error localizedDescription]);
}
}
Be sure to set the the delegate of your MFMailComposeViewController to self.
Apple docs reference here
Of course this only tells you whether the email was successfully sent. There's really no way to know that the email gets delivered on the recipient's end.
Related
I am building a mobile application using Ionic, and decided to use OneSignal for push notifications. I need to have a user be able to click a push notification (text message) and have the app load to a specific page in the app. I was reading information on deep linking, but it's unclear if it applies to what I'm trying to do. I don't want to load anything in a browser.
For example, I may send a text message that says "A new message is available!" If a user clicks the notification, I want to open the application, and go directly to the specific message.
Does someone have an example or can point to the correct documentation?
i have some views about fcm with ionic 3, hope this will help you
this.fcm.onNotification().subscribe(data => {
if(data.wasTapped){
if(data.location == "StoriesPage"){
this.loading = this.loadCtrl.create({
content:'Loading Stories....',
duration:2000
})
this.loading.present();
this.rootPage = HomePage;
} else if(data.location == 'HomePage'){
this.rootPage = HomePage;
} else if(data.location == 'SubscriptionPage'){
this.rootPage = SubscriptionPage;
}
}
console.log("Received in background");
} else {
console.log("Received in foreground");
};
});
here i sent a location attribute as payload of notification data..if based on that i added rootpage
try to approach the same as per your requirement
I made a register form with a email address text field and such, so how do I verify that the email address belongs to the person. Could I make a code that is emailed to the user's email but how do I send emails in Xcode? Or is there some other way to do it with Firebase?
After you've created a user with their email and password, if there are no errors you send them a verification email.
import FirebaseAuth
Auth.auth().currentUser?.sendEmailVerification
{
(error) in
if error != nil
{
print(error!.localizedDescription)
return
}
else
{
//CHECK INBOX FOR CONFIRMATION LINK
}
}
I am using iOS ADAL library version 2.2.6 and receiving refresh token upon successful login. Now I want to make a silent call by using this refresh token. I tried with following method but it fails to return the access token.
ADAuthenticationContext *authContext;
[authContext acquireTokenSilentWithResource:resourceId
clientId:clientId
redirectUri:redirectUri
userId:strUserID //loggedIn userID
completionBlock:^(ADAuthenticationResult *result){
// It alway throws an error //Please call the non-silent acquireTokenWithResource methods.
if(result.error){
ADAuthenticationError *error = nil;
authContext = [ADAuthenticationContext authenticationContextWithAuthority:inputData.authority error:&error];
[authContext acquireTokenWithResource:inputData.ResourceID
clientId:inputData.ClientId // Comes from App Portal
redirectUri:inputData.RedirectUri // Comes from App Portal
completionBlock:^(ADAuthenticationResult *result)
{
if (AD_SUCCEEDED != result.status){
// Show alert with error description
}
else{
//Handle Success token
}
}];
}else{
//Handle Success token
}
}];
But it always throws an error saying "The user credentials are needed to obtain access token. Please call the non-silent acquireTokenWithResource methods."
Is there any way to make a silent call using refresh token? please help me on it. Thanks in advance.
When you use Microsoft's authentication libraries, you should always first check to see if there is a user in the cache that can be used for your resource before prompting the user to sign in. This allows us to check if the user had previously signed in to your app or if there are other apps that share state with your app that may have already asked the user to sign in elsewhere.
If the user is found, we will try to acquire a token without interrupting the user at all. Sometimes a user will have changed their password or done some other action that will require them to sign in again even if they have signed in to your app previously. This is what you are seeing. The library is telling you that for the user you are trying to acquire a token for, they need to sign in again to make something right.
In order to handle all these cases elegantly, we recommend that you use the pseudocode pattern of:
acquireTokenSilent()
(if error InteractiveAuthenticationRequired) {
acquireTokenInteractively() }
The pattern first checks if a user you specify is available in the token cache. If it is, we then call the Azure Active Directory service to see if the Refresh token for that user is valid. If both of these are true, then the user is signed in silently. If the user isn't found or the server rejects the Refresh Token, then an error is sent from the library that indicates the user needs to sign in interactively.
In the above, you are doing this first part, but you aren't handling the case where the user needs to sign in if there is a problem.
The best way is to catch the error with a ADErrorCode of AD_ERROR_USER_INPUT_NEEDED
Here is a code sample on how to do this pattern.
// Here we try to get a token from the stored user information we would have from a successful authentication
[authContext acquireTokenSilentWithResource:data.resourceId
clientId:data.clientId
redirectUri:redirectUri
userId:data.userItem.userInformation.userId
completionBlock:^(ADAuthenticationResult *result) {
if (!result.error)
{
completionBlock(result.tokenCacheStoreItem.userInformation, nil);
} else {
if ([result.error.domain isEqual:ADAuthenticationErrorDomain] && result.error.code == AD_ERROR_USER_INPUT_NEEDED) {
// Here we know that input is required because we couldn't get a token from the cache
[authContext acquireTokenWithResource:data.resourceId
clientId:data.clientId
redirectUri:redirectUri
userId:data.userItem.userInformation.userId
completionBlock:^(ADAuthenticationResult *result) {
if (result.status != AD_SUCCEEDED)
{
completionBlock(nil, result.error);
}
else
{
data.userItem = result.tokenCacheStoreItem;
completionBlock(result.tokenCacheStoreItem.userInformation, nil);
}
}];
} else {
completionBlock(nil, result.error);
}
}
}];
Keep in mind this code is very verbose. You will most likely want to have acquireTokenWithResource: a separate method that you could call with [self acquireTokenWithResource]
I am working on a iOS chatting app by use parse as backend service. If user blocks another user, how to prevent the push notifications? Is that possible to filter this push notification in parse side?
Really appreciate in advance.
There are several different ways to block a push notification from being sent to a user that blocked the sender. It really depends on how you handle the blocking of the user.
You could, for instance, add a blockedUsernames array to each user. If you did this, you could block the push notification from being sent in the first place, by cross checking this blocked users array against the users it is being sent to.
// CHECK FOR BLOCKED USERS
PFUser *currentUser = [PFUser currentUser]; // user sending push
PFUser *sendPushToUser = //user receiving the push
// Get array of blocked users
NSMutableArray *blockedUsersArray = sendPushToUser[#"blockedUsers"];
BOOL blocked = false;
for (NSString *username in blockedUsersArray) {
if ([username isEqualToString:currentUser.username]) {
blocked = true;
}
}
// If the user isn't blocked, send push
if (blocked == false) {
[PFCloud callFunctionInBackground:#"sendPushToUser"
// more cloud code to handle the notification...
You could also block the push notification in the Parse Cloud Code, with some JS.
I have a requirement that I have to send an email and show them in sent items. Using iOS mail API. I can send the email. But I am not able to retrieve the sent items.
Is there any possible way to store the sent email and show them in sent items with all the details like ( to, message body,...) ?
Is it possible to fetch any information from MFMailComposeViewController in the delegate methods?
-(void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:
(MFMailComposeResult)result error:(NSError *)error {
// Any way to fetch sent mail info
}
You can set MFMailComposeViewControllerDelegate in your code. This delegate has a method
- mailComposeController:didFinishWithResult:error:
which sends the results enum through which you can figure out if the mail was sent or not. Then you can save your email message/subject and show the user list of emails they have sent.