I'm building a GCM extension which an AS3 developer can set the location of an mp3 file on sdcard and when the GCM notification runs, that custom sound plays. all good, all fine.
but when I close my air app and send a notification from server, android default sound will be played. and that happens because when the air app is closed, its context is null and the extension does not have access to the parameters set by the app, so it plays the default sound.
I know I can create resources inside the .ane and use them as a custom sound but I don't want to do that. I want to leave the AS3 developer with the freedom to chose the location of the sound file himself.
any ideas?
Thanks,
Hadi
it's a shameless self promotion but I think it's good to tell people who are looking for this to checkout the finished extension here: http://myappsnippet.com/gcm/
the air extension supports custom custom sounds and icons!
You're probably going to have to add some settings to the application that get stored somewhere within the native Android scope and access them from within your GCM notification receiver.
Have a look at SharedPreferences
http://developer.android.com/reference/android/content/SharedPreferences.html
For example:
//
// Save a shared preference
SharedPreferences sharedPreferences = context.getActivity().getSharedPreferences( "YOUR_PREFERENCES_NAME", Activity.MODE_PRIVATE );
Editor preferencesEditor = sharedPreferences.edit();
preferencesEditor.putString( "customNotificationSound", soundLocation );
preferencesEditor.commit();
Then in your receiver:
SharedPreferences sharedPreferences = context.getActivity().getSharedPreferences( "YOUR_PREFERENCES_NAME", Activity.MODE_PRIVATE );
String soundLocation = sharedPreferences.getBoolean( "customNotificationSound", false );
Related
Since AppCenter retiring at the end of this year, I have started migrating to Azure-Notification-Hub.
But the documentation for notification-hub is not clear at all. Especially the documentation for Xamarin.Android. It does not match with their latest SDK.
In the latest (version 1.1.1) azure-notification-hub SDK for Android (or Xamarin.Android) there's no need to implement FirebaseMessagingService. NotificationHub.Start() method registers the device in the Notification-Hub. A device registered with this way gets notifications without any problem.
NotificationHub.Start(Application, <HubName>, <ConnectionString>);
Addition tags to existing NotificationHub instance are also straightforward with the new SDK.
NotificationHub.AddTag("username:user123");
But in Registration Management official doc states that devices can register with the notification-hub either from client-side or from server-side. Is it necessary to use one of those methods if my app registered with the notification-hub using the NotificationHub.Start() method? Or do I missing something?
Also, when I was using the AppCenter, I have used the AppCenter-InstallId to target a specific device.
With that in mind is it possible to use the NotificationHub.InstallationId to use as a tag (eg: "handle:<devce's InstallationId>") to send device-specific notifications?
Is it necessary to use one of those methods if my app registered with the notification-hub using the NotificationHub.Start() method?
When you invoke NotificationHub.start(Application, ...), the Android SDK will listen for changes like added tags, new FirebaseMessagingService tokens, etc. Anytime it detects a change, it will invoke an InstallationAdapter to inform a backend of the new details.
The default InstallationAdapter will send an PUT request to the Azure Notification Hubs backend as documented here. This is what is created by NotificationHub.start(Application, string, string); for people who are not hosting their own backend, this is a sensible default.
If you have your own backend where you track devices, or you're just looking to keep your credentials server-side, you can swap out the InstallationAdapter to be a class that invokes your API. All you need to do is implement the InstallationAdapter interface and initialize the SDK by calling NotificationHub.start(Application, InstallationAdapter).
If you use the NotificationHub.start(...) methods as indicated above, there is no further registration action required.
With that in mind is it possible to use the NotificationHub.InstallationId to use as a tag (eg: "handle:<devce's InstallationId>") to send device-specific notifications?
Yes! This documentation walks you through how to use the special tag format $InstallationId:{YOUR_TAG_ID} to target a specific device.
When you've used NotificationHub.start(), if you do not specify an InstallationId, it will generate one for you.
Question about setting the InstallationId and/or UserId. If I'm using Microsoft.Azure.NotificationHubs.Client, which makes more sense to do.
Should I set the InstallationId via the $InstallationId Tag (see here: https://learn.microsoft.com/en-us/azure/notification-hubs/notification-hubs-push-notification-registration-management#installations) or via implementing the InstallationEnrichmentAdapter and set it via a call to installation.InstallationId = in the EnrichInstallation method?
Additionally, the Microsoft.Azure.NotificationHubs.Client.Installation class provides a UserId property that can be updated too.
I'm also moving my push notifications from AppCenter to Azure Notification Hub and want to reuse my existing AppCenter InstallId.
i am able to add tags and userid as below(java)
NotificationHub.start(this.getApplication(), BuildConfig.hubName, BuildConfig.hubListenConnectionString);
NotificationHub.setInstallationId("123");
Set<String> tags = new HashSet<>();
tags.add("role_memeber");
NotificationHub.setUserId("123");
NotificationHub.addTags(tags);
sdk: com.microsoft.azure:notification-hubs-android-sdk:1.1.6
I have been looking for a method in order to add the google-services.json at runtime as we use same base code to configure the application for the different client, hence we want to add google-services.json at runtime.
I have tried several links but am unable to find such a way to do it.
Any help will be very much appreciated.
The google-services.json is actually never read at runtime. During the build process of your Android app, the relevant information from google-services.json is translated into your App's XML resources, and that is where it's read when the app starts. Since the destination where the build plugin puts the values is hard-wired, you can't configure it to have multiple sets of configuration data.
Instead of trying to read google-services.json at runtime, I'd recommend configuring the FirebaseApp instance in your code explicitly, like this:
// Manually configure Firebase Options
FirebaseOptions options = new FirebaseOptions.Builder()
.setApplicationId("1:27992087142:android:ce3b6448250083d1") // Required for Analytics.
.setApiKey("AIzaSyADUe90ULnQDuGShD9W23RDP0xmeDc6Mvw") // Required for Auth.
.setDatabaseUrl("https://myproject.firebaseio.com") // Required for RTDB.
.build();
Now you can determine yourself where to keep the relevant information from the google-services.json and which ones to use when the app starts.
and then:
// Initialize with secondary app.
FirebaseApp.initializeApp(this /* Context */, options, "secondary");
// Retrieve secondary app.
FirebaseApp secondary = FirebaseApp.getInstance("secondary");
// Get the database for the other app.
FirebaseDatabase secondaryDatabase = FirebaseDatabase.getInstance(secondary);
Also see:
The documentation section on using multiple build flavors (where I now copied the code snippets from)
My previous answer on a related topic (where I think the code snippets in the docs originated 😀)
I am having an AIR application which uses camera/microphone. Need to know if the user has selected "deny access" on IOS 8 ipad, then how the app will be able to detect?
The camera or the microphone are native functions so in AIR in order to access them you need native extensions. If you have a native extension already you should have a method like isSupported that returns true or false if the user allowed access to mic or camera. If you don't have a method like above you need to add one and use native code to check that user give permission for each platform in your case for iOS.
You can definitely access the microphone without an ANE via flash.media.Microphone.
I'm guessing getMicrophone() would return null if denied:
mic = Microphone.getMicrophone();
if (mic==null) {
// No microphone found or access denied
}
And this is very old (2009) but here's an example AIR project using the microphone you could reference.
Is it possible to access phone data like (Contact,Message) in android,Iphone using Flash Builder Mobile Development app .... If It's Possible using Adobe air so tell me ..
thanks
If the underlying operating system exposes that data, you can access it using a Native Extension. You may have to write your own Native Extension to do that, though.
You can call these API's -
Accelerometer
GPS
Camera
Microphone
To store data-
Sql Lite Datebases
OS Interactions-
Text Message
Email
Call
Example-
protected function sendMessage(event:MouseEvent):void {
var message:String = "";
message +="sms:";
message+ = sendTo.text;
navigateToURL ( new URLRequest (message));
}
This should open your messaging app. However the data you to want to read is mostly going to be protected. You can write a Native Extension though and plug Flex into it.
I'm creating a Qt Symbian application and need to connect to internet. In some way I need to let the user choose a connection ONCE when the app starts or use the DEFAULT connection if that is enabled.
Before I just used qt_SetDefaultIap() to set the connection on start. It worked perfect but now I need to use QtMobility instead. I have tried the following in QMainWindow when my app starts:
QNetworkConfigurationManager manager;
const bool selectIap = (manager.capabilities()& QNetworkConfigurationManager::CanStartAndStopInterfaces);
QNetworkConfiguration defaultIap = manager.defaultConfiguration();
if(!defaultIap.isValid() && (!selectIap && defaultIap.state() != QNetworkConfiguration::Active))
{
// let the user know that there is no access point available
}
session = new QNetworkSession(defaultIap,this);
session->open();
But there must be something I'm missing as the application always asks the user to choose connection each time it uses internet not just once as I want. And even if I choose a connection the application asks three times. EDIT: It works on Nokia 5800 but not on N97.
This seems to be a problem for many people as it has been discussed before:
http://discussion.forum.nokia.com/forum/showthread.php?196396-how-to-use-QNetworkConfigurationManager-to-handle-access-point
http://discussion.forum.nokia.com/forum/showthread.php?199401-How-to-use-bearer-management-to-select-access-point
http://discussion.forum.nokia.com/forum/showthread.php?199472-How-can-I-set-the-best-one-access-point-as-default
Any ideas on how to get this working?
if your phone settings are set as 'Always ask' in (5800) Menu -> Settings -> Destinations -> Options -> Default connection, then QNetworkConfigurationManager.defaultConfiguration() will return the UserChoice configuration, which will always popup a query.
If you wish to control which access point is really used, then you could enumerate/list the configurations (QNetworkConfigurationManager::allConfigurations(), choose the one you want, and then create a QNetworkSession based on it and call QNetworkSession::open(). After that if you instantiate and use e.g. QNetworkAccessManager to perform web queries, they should use that configuration "automatically".