├── SCsub ├── admob ├── icon.png.flags ├── icon.png ├── admob.scn ├── .fscache ├── engine.cfg ├── .gd ├── admob_manager.gd └── export.cfg ├── GodotGooglePlayServices ├── SCsub ├── config.py ├── AndroidManifestChunk.xml └── GodotGooglePlayServices.java ├── config.pyc ├── config.py ├── AndroidManifestChunk.xml ├── README.md └── GodotGooglePlayServices.java /SCsub: -------------------------------------------------------------------------------- 1 | Import('env') 2 | -------------------------------------------------------------------------------- /admob/icon.png.flags: -------------------------------------------------------------------------------- 1 | gen_mipmaps=false 2 | -------------------------------------------------------------------------------- /GodotGooglePlayServices/SCsub: -------------------------------------------------------------------------------- 1 | Import('env') 2 | -------------------------------------------------------------------------------- /config.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teamblubee/bbAdmob/HEAD/config.pyc -------------------------------------------------------------------------------- /admob/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teamblubee/bbAdmob/HEAD/admob/icon.png -------------------------------------------------------------------------------- /admob/admob.scn: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teamblubee/bbAdmob/HEAD/admob/admob.scn -------------------------------------------------------------------------------- /admob/.fscache: -------------------------------------------------------------------------------- 1 | ::res://::1427443135 2 | .gd::GDScript::1427440853:: 3 | admob.scn::PackedScene::1427443131:: 4 | admob_manager.gd::GDScript::1427443135:: 5 | icon.png::ImageTexture::1427439582:: 6 | -------------------------------------------------------------------------------- /admob/engine.cfg: -------------------------------------------------------------------------------- 1 | [application] 2 | 3 | name="admob" 4 | main_scene="res://admob.scn" 5 | icon="icon.png" 6 | 7 | [display] 8 | 9 | width=480 10 | height=854 11 | 12 | [android] 13 | modules="com/android/godot/GodotGooglePlayServices" -------------------------------------------------------------------------------- /config.py: -------------------------------------------------------------------------------- 1 | def can_build(plat): 2 | return plat == 'android' 3 | 4 | def configure(env): 5 | if env['platform'] == 'android': 6 | env.android_module_file("GodotGooglePlayServices.java") 7 | env.android_module_manifest("AndroidManifestChunk.xml") 8 | -------------------------------------------------------------------------------- /GodotGooglePlayServices/config.py: -------------------------------------------------------------------------------- 1 | def can_build(plat): 2 | return plat == 'android' 3 | 4 | def configure(env): 5 | if env['platform'] == 'android': 6 | env.android_module_file("GodotGooglePlayServices.java") 7 | env.android_module_manifest("AndroidManifestChunk.xml") 8 | -------------------------------------------------------------------------------- /AndroidManifestChunk.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /GodotGooglePlayServices/AndroidManifestChunk.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /admob/.gd: -------------------------------------------------------------------------------- 1 | 2 | extends Button 3 | 4 | var admob_app_id = "ca-app-pub-xxxxxxxxxxxxxxxxxxxxxxxxxxx" #get this string when you register your app in adbmob backend 5 | 6 | func _init(): 7 | if(Globals.has_singleton("bbAdmob")): 8 | admob = Globals.get_singleton("bbAdmob") 9 | #You can call admob.init_admob_test or admob.init_admob_real 10 | #If the second argument is true, the banner ad will be at the top of the screen 11 | #Function prototype init_admob_test(final String app_id, boolean isTop) 12 | admob.init_admob_test(admob_app_id, true) 13 | 14 | func _ready(): 15 | # Initialization here 16 | pass 17 | 18 | 19 | 20 | 21 | 22 | func _on_Show_Banner_Button_pressed(): 23 | admob.show_banner() 24 | 25 | 26 | func _on_Hide_Banner_Button_pressed(): 27 | admob.hide_banner() 28 | 29 | 30 | func _on_Show_Interstitial_Button_pressed(): 31 | admob.show_interstitial() 32 | -------------------------------------------------------------------------------- /admob/admob_manager.gd: -------------------------------------------------------------------------------- 1 | 2 | extends Button 3 | 4 | var admob = null 5 | #get this string when you register your app in adbmob backend 6 | #If you do not put the correct app publisher id, you won't get any ads 7 | var admob_app_id = "ca-app-pub-xxxxxxxxxxxxxxxxxxxxxxxxxxx" 8 | 9 | func _init(): 10 | if(Globals.has_singleton("bbAdmob")): 11 | admob = Globals.get_singleton("bbAdmob") 12 | #You can call admob.init_admob_test or admob.init_admob_real 13 | #If the second argument is true, the banner ad will be at the top of the screen 14 | #Function prototype init_admob_test(final String app_id, boolean isTop) 15 | admob.init_admob_test(admob_app_id, true) 16 | # connect("pressed", self, "_on_Show_Banner_Button_pressed") 17 | 18 | func _ready(): 19 | # Initialization here 20 | pass 21 | 22 | 23 | 24 | func _on_Show_Banner_Button_pressed(): 25 | admob.show_banner() 26 | 27 | 28 | func _on_Hide_Banner_Button_pressed(): 29 | admob.hide_banner() 30 | 31 | 32 | func _on_Show_Interstitial_Button_pressed(): 33 | admob.show_interstitial() 34 | 35 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # bbAdmob 3 | 4 | [![Godot Google Play Services Admob Video](http://img.youtube.com/vi/lpAkgrIvICc/0.jpg)](http://www.youtube.com/watch?v=lpAkgrIvICc) 5 | 6 | 7 | This is a [Google Play Services module](https://developer.android.com/google/play-services/index.html) for the [Godot game engine](https://github.com/okamstudio/godot), written by [blubee](http://blubee.me) 8 | 9 | This module should be straigh forward to use. 10 | 11 | Setup your app in the new Google Play Services back end, you'll need your "ca-app-pub" number. 12 | 13 | Download this project put the "GodotGooglePlayServices" inside your godot-src/modules foler. 14 | Then recompile your android export templates. 15 | 16 | [How To Compiling Android Export Templates](https://github.com/okamstudio/godot/wiki/compiling_android#compiling-export-templates) 17 | 18 | In the Godot editor go to the export tab 19 | Click on Android 20 | Make sure that **Access Network State** and **internet** permissions are checked 21 | 22 | In your script create a variable, instantiate that variable after checking that it's available to to engine. 23 | 24 | this is where you'll also need your "ca-app-pub". 25 | 26 | Store that as a string and pass it into the init_admob_ function 27 | 28 | 29 | ###Function prototype 30 | ####init_admob_test("banner pub id", "interstitial pub id", "isTop") 31 | ####init_admob_interstitial_test("interstitial pub id", "isTop") 32 | ####init_admob_banner_test("banner pub id", "isTop") 33 | 34 | Replace _test with _real after you've successfully tested the ads. Do not test with live ads because clicking your own ads **even by accident** can cause you to lose your admob account. 35 | 36 | **Also note** 37 | You should only call one of the init_admob_ functions. 38 | 39 | var admob = null 40 | if(Globals.has_singleton("bbAdmob")): 41 | admob = Globals.get_singleton("bbAdmob") 42 | 43 | You then call admob.init_admob_[**test**|**real**] 44 | 45 | once that's done and an ad is successfully loaded you can request to show banner or interstitial ads. 46 | 47 | 48 | With the new Admob you can have separate publisher IDs for your banners and your interstitials. 49 | Calling the main functions init_admob with your banner publisher id as the first argument and your interstitial publisher id as the second argument isTop is boolean true or false. This will load both ad and once they are ready you can call show/ hide banner or show interstitial. 50 | 51 | Remember that you should only call the init function **once**. 52 | 53 | ##Main Functions Overview 54 | 55 | #####admob.init_admob_test("banner pub id", "interstitial pub id", "isTop") 56 | #####admob.init_admob_real("banner pub id", "interstitial pub id", "isTop") 57 | ####admob.show_banner() 58 | ####admob.hide_banner() 59 | ####admob.show_interstitial() 60 | 61 | 62 | If you for any reason would just like to show either interstitial ads or banner ads then call one of these sets of functions below. 63 | 64 | 65 | 66 | ###Additional Functions 67 | #####admob.init_admob_interstitial_test("interstitial pub id", "isTop") 68 | #####init_admob_interstitial_real("interstitial pub id", "isTop") 69 | #####init_admob_banner_test("banner pub id", "isTop") 70 | #####init_admob_banner_real("banner pub id", "isTop") 71 | 72 | 73 | Be sure to always test your ads with the **init_admob_test** functions, Google will band your admob account if you test with real ads. To be sure check the [admob guidelines](https://support.google.com/admob/answer/2753860?hl=en) 74 | 75 | I've also added added proper lifecycle handling code, that means if your showing a banner ad before your app goes into the background, the banner ad will handle that properly. 76 | 77 | 78 | check the example project for usage. 79 | 80 | ###credit 81 | This [StackOverflow](http://stackoverflow.com/questions/3934331/android-how-to-encrypt-a-string) answer for getting android device id. 82 | -------------------------------------------------------------------------------- /admob/export.cfg: -------------------------------------------------------------------------------- 1 | [convert_images] 2 | 3 | action="none" 4 | compress_quality=0.7 5 | formats="png" 6 | shrink=1 7 | 8 | [export_filter] 9 | 10 | filter="" 11 | type="resources" 12 | 13 | [platform:Android] 14 | 15 | apk_expansion/SALT="" 16 | apk_expansion/enable=false 17 | apk_expansion/public_key="" 18 | command_line/extra_args="" 19 | custom_package/debug="" 20 | custom_package/release="" 21 | keystore/release="" 22 | keystore/release_password="" 23 | keystore/release_user="" 24 | one_click_deploy/clear_previous_install=true 25 | package/icon="" 26 | package/name="" 27 | package/signed=true 28 | package/unique_name="com.android.noname" 29 | permissions/access_checkin_properties=false 30 | permissions/access_coarse_location=false 31 | permissions/access_fine_location=false 32 | permissions/access_location_extra_commands=false 33 | permissions/access_mock_location=false 34 | permissions/access_network_state=true 35 | permissions/access_surface_flinger=false 36 | permissions/access_wifi_state=false 37 | permissions/account_manager=false 38 | permissions/add_voicemail=false 39 | permissions/authenticate_accounts=false 40 | permissions/battery_stats=false 41 | permissions/bind_accessibility_service=false 42 | permissions/bind_appwidget=false 43 | permissions/bind_device_admin=false 44 | permissions/bind_input_method=false 45 | permissions/bind_nfc_service=false 46 | permissions/bind_notification_listener_service=false 47 | permissions/bind_print_service=false 48 | permissions/bind_remoteviews=false 49 | permissions/bind_text_service=false 50 | permissions/bind_vpn_service=false 51 | permissions/bind_wallpaper=false 52 | permissions/bluetooth=false 53 | permissions/bluetooth_admin=false 54 | permissions/bluetooth_privileged=false 55 | permissions/brick=false 56 | permissions/broadcast_package_removed=false 57 | permissions/broadcast_sms=false 58 | permissions/broadcast_sticky=false 59 | permissions/broadcast_wap_push=false 60 | permissions/call_phone=false 61 | permissions/call_privileged=false 62 | permissions/camera=false 63 | permissions/capture_audio_output=false 64 | permissions/capture_secure_video_output=false 65 | permissions/capture_video_output=false 66 | permissions/change_component_enabled_state=false 67 | permissions/change_configuration=false 68 | permissions/change_network_state=false 69 | permissions/change_wifi_multicast_state=false 70 | permissions/change_wifi_state=false 71 | permissions/clear_app_cache=false 72 | permissions/clear_app_user_data=false 73 | permissions/control_location_updates=false 74 | permissions/delete_cache_files=false 75 | permissions/delete_packages=false 76 | permissions/device_power=false 77 | permissions/diagnostic=false 78 | permissions/disable_keyguard=false 79 | permissions/dump=false 80 | permissions/expand_status_bar=false 81 | permissions/factory_test=false 82 | permissions/flashlight=false 83 | permissions/force_back=false 84 | permissions/get_accounts=false 85 | permissions/get_package_size=false 86 | permissions/get_tasks=false 87 | permissions/get_top_activity_info=false 88 | permissions/global_search=false 89 | permissions/hardware_test=false 90 | permissions/inject_events=false 91 | permissions/install_location_provider=false 92 | permissions/install_packages=false 93 | permissions/install_shortcut=false 94 | permissions/internal_system_window=false 95 | permissions/internet=true 96 | permissions/kill_background_processes=false 97 | permissions/location_hardware=false 98 | permissions/manage_accounts=false 99 | permissions/manage_app_tokens=false 100 | permissions/manage_documents=false 101 | permissions/master_clear=false 102 | permissions/media_content_control=false 103 | permissions/modify_audio_settings=false 104 | permissions/modify_phone_state=false 105 | permissions/mount_format_filesystems=false 106 | permissions/mount_unmount_filesystems=false 107 | permissions/nfc=false 108 | permissions/persistent_activity=false 109 | permissions/process_outgoing_calls=false 110 | permissions/read_calendar=false 111 | permissions/read_call_log=false 112 | permissions/read_contacts=false 113 | permissions/read_external_storage=false 114 | permissions/read_frame_buffer=false 115 | permissions/read_history_bookmarks=false 116 | permissions/read_input_state=false 117 | permissions/read_logs=false 118 | permissions/read_phone_state=false 119 | permissions/read_profile=false 120 | permissions/read_sms=false 121 | permissions/read_social_stream=false 122 | permissions/read_sync_settings=false 123 | permissions/read_sync_stats=false 124 | permissions/read_user_dictionary=false 125 | permissions/reboot=false 126 | permissions/receive_boot_completed=false 127 | permissions/receive_mms=false 128 | permissions/receive_sms=false 129 | permissions/receive_wap_push=false 130 | permissions/record_audio=false 131 | permissions/reorder_tasks=false 132 | permissions/restart_packages=false 133 | permissions/send_respond_via_message=false 134 | permissions/send_sms=false 135 | permissions/set_activity_watcher=false 136 | permissions/set_alarm=false 137 | permissions/set_always_finish=false 138 | permissions/set_animation_scale=false 139 | permissions/set_debug_app=false 140 | permissions/set_orientation=false 141 | permissions/set_pointer_speed=false 142 | permissions/set_preferred_applications=false 143 | permissions/set_process_limit=false 144 | permissions/set_time=false 145 | permissions/set_time_zone=false 146 | permissions/set_wallpaper=false 147 | permissions/set_wallpaper_hints=false 148 | permissions/signal_persistent_processes=false 149 | permissions/status_bar=false 150 | permissions/subscribed_feeds_read=false 151 | permissions/subscribed_feeds_write=false 152 | permissions/system_alert_window=false 153 | permissions/transmit_ir=false 154 | permissions/uninstall_shortcut=false 155 | permissions/update_device_stats=false 156 | permissions/use_credentials=false 157 | permissions/use_sip=false 158 | permissions/vibrate=false 159 | permissions/wake_lock=false 160 | permissions/write_apn_settings=false 161 | permissions/write_calendar=false 162 | permissions/write_call_log=false 163 | permissions/write_contacts=false 164 | permissions/write_external_storage=false 165 | permissions/write_gservices=false 166 | permissions/write_history_bookmarks=false 167 | permissions/write_profile=false 168 | permissions/write_secure_settings=false 169 | permissions/write_settings=false 170 | permissions/write_sms=false 171 | permissions/write_social_stream=false 172 | permissions/write_sync_settings=false 173 | permissions/write_user_dictionary=false 174 | screen/orientation=0 175 | screen/support_large=true 176 | screen/support_normal=true 177 | screen/support_small=true 178 | screen/support_xlarge=true 179 | user_permissions/0="" 180 | user_permissions/1="" 181 | user_permissions/10="" 182 | user_permissions/11="" 183 | user_permissions/12="" 184 | user_permissions/13="" 185 | user_permissions/14="" 186 | user_permissions/15="" 187 | user_permissions/16="" 188 | user_permissions/17="" 189 | user_permissions/18="" 190 | user_permissions/19="" 191 | user_permissions/2="" 192 | user_permissions/3="" 193 | user_permissions/4="" 194 | user_permissions/5="" 195 | user_permissions/6="" 196 | user_permissions/7="" 197 | user_permissions/8="" 198 | user_permissions/9="" 199 | version/code=1 200 | version/name="1.0" 201 | 202 | [platform:BlackBerry 10] 203 | 204 | package/category="core.games" 205 | package/custom_template="" 206 | package/description="Game made with Godot Engine" 207 | package/icon="" 208 | package/name="" 209 | package/unique_name="com.godot.noname" 210 | release/author="Cert. Name" 211 | release/author_id="Cert. ID" 212 | version/code=1 213 | version/name="1.0" 214 | 215 | [platform:HTML5] 216 | 217 | browser/enable_run=false 218 | custom_package/debug="" 219 | custom_package/release="" 220 | options/memory_size=3 221 | 222 | [platform:Linux X11] 223 | 224 | binary/64_bits=true 225 | custom_binary/debug="" 226 | custom_binary/release="" 227 | resources/pack_mode=1 228 | 229 | [platform:Mac OSX] 230 | 231 | application/64_bits=false 232 | application/copyright="" 233 | application/icon="" 234 | application/identifier="com.godot.macgame" 235 | application/info="This Game is Nice" 236 | application/name="" 237 | application/short_version="1.0" 238 | application/signature="godotmacgame" 239 | application/version="1.0" 240 | custom_package/debug="" 241 | custom_package/release="" 242 | display/high_res=false 243 | 244 | [platform:Windows Desktop] 245 | 246 | binary/64_bits=true 247 | custom_binary/debug="" 248 | custom_binary/release="" 249 | resources/pack_mode=1 250 | 251 | [script] 252 | 253 | action="compile" 254 | encrypt_key="" 255 | -------------------------------------------------------------------------------- /GodotGooglePlayServices/GodotGooglePlayServices.java: -------------------------------------------------------------------------------- 1 | package com.android.godot; 2 | 3 | import android.util.Log; 4 | import android.view.View; 5 | import android.app.Activity; 6 | import com.google.android.gms.ads.*; 7 | 8 | import android.view.Gravity; 9 | import android.widget.FrameLayout; 10 | import android.view.ViewGroup.LayoutParams; 11 | 12 | import android.provider.Settings; 13 | import java.security.MessageDigest; 14 | import java.security.NoSuchAlgorithmException; 15 | 16 | public class GodotGooglePlayServices extends Godot.SingletonBase { 17 | 18 | private Activity m_activity; 19 | private AdView m_adview; 20 | private AdRequest m_adrequest; 21 | private AdRequest i_adrequest; 22 | private AdListener m_adlistener; 23 | private InterstitialAd m_interstitial; 24 | 25 | private boolean isBannerOnTop = false; 26 | private boolean isShowingBanner = false; 27 | private boolean isBannerReady = false; 28 | private boolean isinterstitialReady = false; 29 | private boolean isInterstitialShowing = false; 30 | private boolean isDebug; 31 | private boolean isTest; 32 | 33 | private String m_app_id; 34 | 35 | static public Godot.SingletonBase initialize(Activity p_activity) { 36 | 37 | return new GodotGooglePlayServices(p_activity); 38 | } 39 | 40 | public GodotGooglePlayServices(Activity p_activity) { 41 | 42 | registerClass("bbAdmob", new String[]{"init_admob_test","init_admob_real","show_banner","hide_banner","show_interstitial"}); 43 | m_activity = p_activity; 44 | 45 | } 46 | 47 | private String get_device_id(){ 48 | String device_id_string = Settings.Secure.getString(m_activity.getContentResolver(), Settings.Secure.ANDROID_ID); 49 | String admobDeviceId = md5(device_id_string).toUpperCase(); 50 | 51 | return admobDeviceId; 52 | } 53 | 54 | private String md5(final String s) { 55 | try { 56 | // Create MD5 Hash 57 | MessageDigest digest = java.security.MessageDigest.getInstance("MD5"); 58 | 59 | digest.update(s.getBytes()); 60 | byte messageDigest[] = digest.digest(); 61 | 62 | // Create Hex String 63 | StringBuffer hexString = new StringBuffer(); 64 | for(int i=0; i