How to add toast message in your tweak

I found a project that can display a toast message in iOS which has the same functionality as Toast in Android

Download Toast project as zip scalessec/Toast

Extract Toast folder to your tweak

In your Makefile, Add UIView+Toast.m to [PROJECTNAME]_FILES

In your tweak.xm, Include UIView+Toast.h like

#include "Toast/UIView+Toast.h"

And add your UIView variable and hook view controller like UIViewController

UIView *uiView;

//Set our view variable
%hook UIViewController
  -(void)viewDidLoad {
    %orig;
    uiView = self.view;
  }
%end

If UIViewController doesn’t work, try other views.

Now you can use it like:

static void didFinishLaunching(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef info) {
  timer(2) {

    [uiView makeToast:@"Modded by AndnixSH\nPlatinmods.com - The gaming community"];
    load();
    });
}

void launchEvent() {
    CFNotificationCenterAddObserver(CFNotificationCenterGetLocalCenter(), NULL, &didFinishLaunching, (CFStringRef)UIApplicationDidFinishLaunchingNotification, NULL, CFNotificationSuspensionBehaviorDrop);
}

__attribute__((constructor)) static void initialize() {
    launchEvent();
}

More example can be seen on Github. You may need to replace “self.view” with your UIView variable if you are using it within C++ side

Preview:

Image 2023 05 28 14 52 29.png

Comments

Popular Posts

VMOS Pro Global CN FREE Custom ROMs | Gapps, ROOT, Xposed | Android 4.4.4, 5.1.1, 7.1.2, 9.0 ROMs | NO VIP

How to activate VMOS Assistant to run VMOS on Android 12 and above