Activating an app via URL

Eduardo Gomez 3,431 Reputation points
2024-01-24T09:30:06.1366667+00:00

I have a method, to sending meeting URLs

private static string GenerateHttmlTemplate(string roomName, string meetingLink, string userName, DateTime? dateTime = null) {

    return $@"
        <html>
        <head>
            <style>
                /* CSS for the button */
                .button {{
                    background-color: #5C3E88; /* Button background color */
                    color: white; /* Text color */
                    text-decoration: none;
                    padding: 10px 20px; /* Padding around text */
                    border-radius: 5px; /* Rounded corners */
                    display: inline-block;
                }}
            </style>
        </head>
        <body>
            <p>Here are the meeting details:</p>
            <br> <!-- Add a line break -->
            <p><strong>Meeting Name:</strong> {roomName}</p>
            <p><strong>Teacher Name:</strong> {userName}</p>
            <p>Click the button below to join the meeting:</p>
            <p><a class='button' href='{meetingLink}'>Join</a></p>
        </body>
        </html>";
}

public static async Task SendEmail(ObservableCollection<User> users, string roomName, User? user, string meetingLink, DateTime? dateTimeMeeting) {

    try {
        var smtpClient = new SmtpClient("smtp.gmail.com") {
            Port = 587,
            Credentials = new System.Net.NetworkCredential(Constants.EMAIL, Constants.APP_PASSWORD),
            EnableSsl = true,
            DeliveryMethod = SmtpDeliveryMethod.Network
        };

        foreach(var recipient in users) {
            var mail = new MailMessage() {
                From = new MailAddress(Constants.EMAIL),
                Subject = "DemyIA meeting",
                IsBodyHtml = true,
            };

            var body = GenerateHttmlTemplate(roomName, meetingLink, user!.Name, dateTimeMeeting);

            mail.Body = body;

            // Add the recipient to the message
            mail.To.Add(recipient.Email);

            // Send the email asynchronously and await the task
            smtpClient.Send(mail);
        }

        Console.WriteLine("Email sent successfully to the SMTP server.");

    } catch(Exception e) {
        await Console.Out.WriteLineAsync(e.Message);
    }
}


the meeting URL would be something like <a class="m_2472674493776442577button" href="https://demy-ia.daily.co/m" target="_blank" data-saferedirecturl="https://www.google.com/url?q=https://demy-ia.daily.co/m&amp;source=gmail&amp;ust=1706173440151000&amp;usg=AOvVaw05SUaLpzfkd1rvg8_mcIYi">Join</a> The beautiful thing about MAUI, is that you can deploy for windows as well I have this deep link work in Android https://reccloud.com/u/35c18sw As you can see, when I receive a link on my email, it will open my app

[IntentFilter([Intent.ActionView],
                    DataScheme = "https",
                    DataHost = "demy-ia.daily.co",
                    DataPathPattern = "/.*",
                    AutoVerify = true,
                    Categories = [Intent.CategoryDefault, Intent.CategoryBrowsable])]
public class MainActivity : MauiAppCompatActivity {
    protected override void OnNewIntent(Intent? intent) {
        base.OnNewIntent(intent);

        var res = intent!.Data;

        Console.WriteLine(res);
    }

I am trying desperately to do the same on windows. One of the things I can do, is to change the url, to be demy-ai://dedewdew , and whe my application opens, construct the url there is no other way to do this? on Android it was so easy By the way How can I test this

demo https://reccloud.com/u/x189yrw because I was thinking that I can use that, to build the URL for Windows Is there any other options? But if I do this, how I can ake my method send demy-ia://Addyourtestmeetingid only on windows

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,915 questions
{count} votes

Accepted answer
  1. Yonglun Liu (Shanghai Wicresoft Co,.Ltd.) 48,181 Reputation points Microsoft Vendor
    2024-01-26T02:13:25.59+00:00

    Hello,

    Thanks for your feedback.

    This is due to the fact that Android and Windows use different deeplink link wake-up programs.

    As a result, Mail Link for Android does not launch the application for the Windows platform.

    Solution:

    This is really a matter of dynamic generation of HTML, where you need to dynamically add a different prefix to a JavaScript method, such as a page load event or a tag click event, to determine which platform the user clicked on through the JavaScript.

    Since JavaScript is out of scope from MAUI, it is recommended that you refer to the HTML and Javascript documentation for examples.

    An alternative static generation solution: As mentioned above, Windows and Android use different link formats. Therefore, you could generate two join buttons for Android and Windows platforms when generating HTML. Best Regards,

    Alec Liu.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.