Creating AdMob Component Dynamically - mobile

I am having a trouble about Smartface App Studio about creating AdMob component dynamically. How can i do this in Smartface? In former edition, we could use AdMob component in toolbar. It was easy just drag&drop.
So in the new version, i need an example for both (Android and iOS, btw is any difference for both?) about my problem.
Thanks in advance.
Regards.

AdMob component should be added dynamically in your application.
You can create it like;
var admob = new SMF.UI.AdMob();
admob.adSize = SMF.UI.AdMob.AdSize.banner;
admob.adUnitId.Android = "AD_UNIT_ID_Android";
admob.adUnitId.iOS= "AD_UNIT_ID_iOS";
Pages.Page1.add(admob);
var adRequest = new SMF.UI.AdMob.AdRequest();
adRequest.addTestDevice(SMF.UI.AdMob.AdRequest.deviceIDEmulator);
adRequest.addTestDevice("DEVICE_ID");
adRequest.gender = SMF.UI.AdMob.AdRequest.genderFemale;
adRequest.birthday = new Date(2004,10,10);
adRequest.location = {latitude:41, longitude:29};
//You should load it for all pages.
admob.load(adRequest);
For more info please check the link : http://docs.smartface.io/?topic=html/M_SMF_UI_AdMob__ctor.htm
Smartface.io Team

Related

call SharePoint's add new webpart function from within a web part component (spfx-reactjs)

I'm just new to reactjs-spfx controls. I have a pnpjs control that lists all the pages and it's contents. I should be able to add edit and delete pages using that web part. I want to include in that component the functionality to add a new Web part to the page content when I'm editing it. How do you call that functionality from SharePoint to add new webpart? Please see below picture. Thanks.
I would recommend using pnpjs library for this, it wraps most basic tasks with a nice api. I am adding my own webpart to a page something like this, just to give you an idea:
See https://pnp.github.io/pnpjs/sp/clientside-pages/
const sp = SPFI(...)
// or get the existing page
const page = await sp.web.addClientsidePage(fileName, title);
const section = page.addSection();
const partDefs = await sp.web.getClientsideWebParts();
// find the web part we want to add by guid
const myPartDef = partDefs.find(c => areGuidsEqual(c.Id, MY_GUID));
const part = ClientsideWebpart.fromComponentDef(myPartDef);
part.setProperties({
someProp: someValue
});
section.addControl(part);
await page.save();

How to draw map using new Lat Lng in ionic

I am passing proper latitude and longitude to the map but it shows old map, having old lat lng. I know I am doing something wrong in this, but I can't figure out it. My project in ionic framework and for map I am using this plugin map plugin
This my html code
<div style="width:100%;height:200px" id="mapDisplay"></div>
This my angularJS code
var getLat = $scope.dealer.lat;
var getLng = $scope.dealer.lng;
var address = $scope.dealer.address;
var mapDiv = document.getElementById("mapDisplay");
const myGeoLocation = new plugin.google.maps.LatLng(getLat,getLng);
var map = plugin.google.maps.Map.getMap(mapDiv, {
'camera': {
'latLng': myGeoLocation,
'zoom': 15
}
});
map.addEventListener(plugin.google.maps.event.MAP_READY, function() {
map.addMarker({
'position': myGeoLocation,
'title': address
}, function(marker) {
marker.showInfoWindow();
});
});
From the docs of the map plugin you are using
This plugin generates only one map instance using the Map.getMap()
method. In general, you may want to create multiple maps, but this
plugin doesn't allow it.
So your plugin.google.maps.Map.getMap is only grabbing the existing instance, not creating a new one and the plugin.google.maps.event.MAP_READY is only fired once, the first time. However looking at the source code it looks like the instance exposes a remove method which you can use to destroy the existing instance and create a new one with the new sets of coordinates when the callback is called, e.g: map.remove(function() { /** reset map coordinates **/ }
** Extra **
If you just need to display a map with a set of coordinates you can do it using the native app by passing lat/lon to the $cordovaInAppBrowser plugin. As an example for iOS and Android you'd have the following:
iOS
$cordovaInAppBrowser.open('maps://?q=<latitude>,<longitude>', '_system');
Android
$cordovaInAppBrowser.open('geo:0,0?q=<latitude>,<longitude>', '_system');
And finally you need to enable the geo uri in your config.xml like so:
<allow-intent href="geo:*" />
The plugin doesn't allow to create multiple maps instance More detail.
But you can achieve this by using this code
var map = plugin.google.maps.Map.getMap(div);
map.clear();
map.off();
map.trigger("test");
map.addEventListener(plugin.google.maps.event.MAP_READY);

Registration with profile picture using services in Drupal

I've been trying to upload a user profile picture during the user registration using Service 3 and so far I haven't had any luck. I tested passing a hard coded fid in the field "picture" and also tried to pass the fields "filemime", "filename", etc. and it didn't work neither.
Any idea about what fields I need to populate?
I guess it must be related to this post Using Drupal Services and DIOS SDK for setting user picture in iOS app
but it doesn't have and answer neither.
I use following code -
//Picture is first uploaded from ios using file service and fid is passed in $data object
$file_contents_object = file_load($data->picture_fid);
$file_contents_array['fid'] = $file_contents_object->fid;
$file_contents_array['uid'] = $file_contents_object->uid;
$file_contents_array['filename'] = $file_contents_object->filename;
$file_contents_array['uri'] = $file_contents_object->uri;
$file_contents_array['filemime'] = $file_contents_object->filemime;
$file_contents_array['filesize'] = $file_contents_object->filesize;
$file_contents_array['status'] = $file_contents_object->status;
$file_contents_array['timestamp'] = $file_contents_object->timestamp;
$file_contents_array['rdf_mapping'] = $file_contents_object->rdf_mapping;
//use your cck field here
$user_obj->field_user_profile_picture['und'][0] = $file_contents_array;
Hope this will help.

How do you access the iOS Camera Roll from a flex mobile project?

I want to use FlashBuilder 4.5.1 to build a flex mobile project that lets me select multiple photos from the iPhone Camera Roll.
I've seen the flash.media.CameraRoll class, but it only seems to provide CameraRoll.browseForImage() that opens a dialog to pick ONE photo.
Does flex mobile allow something like this:
// is this a security violation?
var cameraRoll:File = new File('/var/mobile/Media/DCIM');
var photos:Array = [];
var folders:Array = cameraRoll.getDirectoryListing();
for (var i:int=0 ; i<folders.length; i++) {
var files:Array = folders[i].getDirectoryListing();
for (var j:int=0 ; j<files.length; j++) {
var photo:File = files[j];
photos.push(photo);
}
}
// show photos, somehow...
However, this method does not provide access to thumbnails managed by: '/var/mobile/User/Media/Photos/Photo Database'
Is there another way to do this?
PS: I'd try this on my iPhone, but I'm still waiting for my iOS development certificate.
Oddly, I don't think your code is an explicit security violation. I do think it would get your app rejected by Apple, though. It seems that the iOS file system is protected, at least in part, by policy rather than security (based on conversations I've had with other developers).

How to list pages in Silverlight Application?

I want to list all pages in application and create instance of these pages programatically. If you have any idea about this please help. Thanks..
I assume you are talking about a Silverlight Navigation application?
If you need to get all types that inherit from System.Windows.Controls.Page in your app you can use:
var pageTypes = typeof(App)
.Assembly
.GetTypes()
.Where(type => typeof(Page).IsAssignableFrom(type));
Then you can iterate over this to get instances of each:
var instances = types.Select(type => Activator.CreateInstance(type));

Resources