Interstitial Ads snippet objective c => https://gist.github.com/dbrova15/d377d42075d8ec99dbf7fd95432cab00. Banner Ads snippet objective c => https://gist.github.com/Dirk-Sandberg/e20854cc833b8a13708892f4ef0909b3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import annotations | |
from typing import Optional | |
from kivy import platform | |
class SingletonMeta(type): | |
_instance: Optional[Singleton] = None | |
def __call__(self) -> Singleton: | |
if self._instance is None: | |
self._instance = super().__call__() | |
return self._instance | |
class Singleton(metaclass=SingletonMeta): | |
def __init__(self): | |
if platform == "ios": | |
from pyobjus import autoclass | |
self.banner_ad = autoclass("adSwitch").alloc().init() | |
self.interstitial_ad = autoclass("adInterstitial").alloc().init() | |
def show_interstitial(self): | |
print("show_interstitial python") | |
if platform == "ios": | |
self.interstitial_ad.InterstitialView() | |
def show_banner(self): | |
print("show_banner python") | |
if platform == "ios": | |
self.banner_ad.show_ads() | |
def hide_banner(self): | |
print("hide_ads python") | |
if platform == "ios": | |
self.banner_ad.hide_ads() | |
if __name__ == "__main__": | |
s1 = Singleton() | |
s2 = Singleton() | |
if id(s1) == id(s2): | |
print("Singleton works, both variables contain the same instance.") | |
else: | |
print("Singleton failed, variables contain different instances.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Interstitial Ads snippet objective c => https://gist.github.com/dbrova15/d377d42075d8ec99dbf7fd95432cab00
Banner Ads snippet objective c => https://gist.github.com/Dirk-Sandberg/e20854cc833b8a13708892f4ef0909b3