How to add `c8y_Address` property to a device using API in cumulocity? - cumulocity

Here is the image of the asset information widget, which can add a property called c8y_Address
I would like my device to show their address information on the asset information widget, but I don't really know how to upload these properties to a device.
I am using MQTT. So I created a customised SMQRT Template, which is a POST inventory method 001,<region>,<street>,<territory>. And then I publish it using client.publish('s/uc/TemplateName',001,${region},${address},${territory});. But it doesn't work.
I'm just wondering how can we use API to add the address information as a property of a device?
Thank you.

POST would create a new object. I guess what you want to do is updating the device with this properties. So a PUT template would be the correct choice.
Note that the preview shown in the UI currently is incorrect for PUT templates.
It says:
999,<c8y_Address.region>,<c8y_Address.street>,<c8y_Address.territory>
but it actually needs to be (like described in the SmartREST 2.0 guide):
999,<externalId>,<c8y_Address.region>,<c8y_Address.street>,<c8y_Address.territory>
The externalId needs to be from the device you want to update (if you only have a single device without children it would be what you also use as MQTT clientId).

Related

How do I notify users of new content available in tvOS apps from the home screen?

Push notifications have been left out of tvOS (understandably so) but the docs seem to contradict themselves in alerting users to the fact that there is something new available in your tvOS app.
Here it seems to say that you can add an app badge: https://developer.apple.com/library/prerelease/tvos/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/WhatAreRemoteNotif.html
Here it says they've been removed from UIKit: https://developer.apple.com/library/prerelease/tvos/releasenotes/General/tvOS90APIDiffs/Objective-C/UIKit.html
Removed UIApplication.applicationIconBadgeNumber
Assuming the badge approach is not supported in this release, does anyone know the best practice for alerting a user that there is new content in your app without the user taking an explicit action? ie focusing on the app and showing them something in TopShelf?
I encountered the same problem and dived into this. Probably your best way is to update the topshelf with latest items, which is my way to solve this for now. You can use network calls to update the topshelf with content from your backend.
This depends on the type of application. E.g. showing the latest top movies for a movies app.
You can trigger an update of the topshelf after your network call completed using the following code:
NSNotificationCenter.defaultCenter().postNotificationName(TVTopShelfItemsDidChangeNotification, object: nil)
Make sure to implement the TVTopShelfProvider which should be clear using the following documentation:
This protocol is adopted by the principal class of an app’s TV Services extension. Apps that implement this extension can provide dynamic content to the Top Shelf element rather than having the system use the static image submitted with the app. The topShelfStyle property specifies the interface style you want, and the topShelfItems property specifies the content items to display. Whenever you change the content provided by the extension, post a TVTopShelfItemsDidChangeNotification notification to prompt the system to reload your content.
Icon badges are removed for app icons, push notifications as well (except for silent push notifications).

How to set message caption using Facebook Messenger SDK for iOS

I need to set a caption when I share a picture (QR code) from my app integrated with Facebook Messenger.
There is metadata NSString field but I don't see a way how to use it. Did anyone solve that problem?
metadata field You can see that we're passing options to the share
method. This contains two fields we want to send back to Messenger:
metadata and contextOverride.
The metadata field takes a NSString and is optional. It can be used to
give information about the content being shared. For example, you can
store a serialized JSON string. This is useful during replies as this
data is passed back to your app.
https://developers.facebook.com/docs/messenger/ios#bp_using_metadata
The metadata is meant for you, as a developer, to use. For example, when a user creates an image from your app you can attach metadata to it, at that point. This metadata is sent, in the background, together with the image to the recipient. When they decide to reply, using your app, you will receive the metadata there.
You can use this, for example, if in your app somebody selected a category to get the image. When you pass in this category in the metadata (which is up to you to format, but JSON is convenient), you get this metadata/JOSN in your app when the recipient replies. You can read the category and load the images on that category already.
The metadata does not set a caption to your image. Actually, there is no integrated way to add a caption to your images.
I would advise to generate the QR-code part of the image and the caption in your app. The image that you post to the Messenger API is thus a combination of the QR-code and a textual caption above or below it. Does that make sense?
ps: about the credible source; I'm a developer support engineer at Facebook :)

Google Map Integration in OS X Application

I would like to use use Google Map in my MAC application.
I found the iOS SDK of Google Maps but not for OS X.
I want to show two annotation and a line connecting them on Google Map. Coordinate of both annotation are dynamic as per user selection.
Below is the way I find out that can work:
Call a API and pass the location coordinate for both annotation.
Now Server side a html form is generate using javascript and create a page which is showing the 2 annotation and line connecting them.
In Api Response I will get the URL of that html page.
I will show this page in UIWebView.
I want to know is there any other way I can achieve this.
I want to distribute application outside the mac app store and to distribute outside mac store I need to sign app with Developer ID which does not support the MAPs.
I didn't find anything related to this that's why I created this thread.
Thanks in advance.
I recently ported the Mapbox iOS SDK over to OS X. It has a lot of the features of MapKit, but it’s open source and should also work in a developer-signed application such as yours. To use the Mapbox OS X SDK, download the latest release from the GitHub repository (look for releases beginning with “osx-”) and follow the instructions in README.md. An API reference is included.
I want to show two annotation and a line connecting them on Google Map. Coordinate of both annotation are dynamic as per user selection.
To display the annotations on-screen, you’ll need the MGLPointAnnotation and MGLPolyline classes. You can move the point annotations dynamically by setting their coordinate properties. The polyline, however, is immutable; to change its path, remove the existing polyline and add a new one with the new coordinates.
You will have to make it with WebKit and the Google Maps API.
MapKit is available in OS X 10.9 Mavericks: https://developer.apple.com/library/mac/documentation/MapKit/Reference/MapKit_Framework_Reference/index.html
There are of course many ways of hiding the fact that you're using WebKit but if they violate Apple's or Google's TOS then submission to the App Store won't be possible.
Hope this will be helpful!

Xcode tag users in image

I want to make something similar to facebook tag mechanism. I will display an image of a building to the users and i want them to be able to tag themselves in which room they are at the moment. The location would be sent to a web server so all users can see other's location. Is that possible and how? Thanks in advance.
It is likely to be possible.
I can suggest the following solution: store the building photo/scheme AND rooms information on server.
In your App, you will display image (perhaps in ScrollView), there you will have just TapGestureRecognizer which will recognize the room, depending on coordinates of tap.
In case of this solution, you will have to manually store information about each tap-zone corresponding to a room. But that's the most likely case.

How to push a local notification When a change happens in input data?

I fetch some data from a url and display data on a tableview. I need to create a local notification and inform(allert) user about the change when a new data is added to data source. How can i create such a notification( it must work even in bacground too)? Any idea-tutorial recommendation will be appropriate. Thanks
You can create local notifications using UILocalNotification. You can either schedule it or present it. Look into Application.h for more info about it.
You can also plainly use notification center to handle such changes.
Some useful link:
http://blog.corywiles.com/uilocalnotification-example-project-using-ios